Regular Number HDU - 5972(Shift-And匹配)

Regular Number

 HDU - 5972 

题意:

用到了bitset和Shift-And匹配算法

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int maxn = 5e6+10;
 4 bitset<1010> B[11], ans;
 5 char s[maxn];
 6 int main(){
 7     int n;
 8     //freopen("in.txt", "r", stdin);
 9    // for(int i = 0 ; i < 11; i++) B[i].reset();
10    // ans.reset();
11     scanf("%d", &n);
12     for(int i = 0; i < n; i++){
13         int m, x;
14         scanf("%d", &m);
15         for(int j = 0; j < m; j++) {
16             scanf("%d", &x);
17             B[x].set(i);
18         }
19     }
20     scanf("%s", s);
21     int len = strlen(s);
22     for(int i = 0; i < len; i++){
23         ans <<= 1;
24         ans[0] = 1;
25         ans &= B[s[i] - '0'];
26         if(ans[n-1] == 1) {
27             char c = s[i+1];
28             s[i+1] = 0;
29             puts(&s[i-n+1]);
30             s[i+1] = c;
31         }
32     }
33     return 0;
34 }
View Code

 

转载于:https://www.cnblogs.com/yijiull/p/7705290.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值