HDU 5972 Regular Number

Posted widsom

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU 5972 Regular Number相关的知识,希望对你有一定的参考价值。

Regular Number
思路:
shifit and算法
代码:

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "
";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 1000 + 10, M = 5e6 + 10;
char s[M];
bitset<N> f[10], g;
int t, x, n;
int main() {
    while(~scanf("%d", &n)) {
        for (int i = 0; i < 10; ++i) f[i].reset();
        g.reset();
        for (int i = 0; i < n; ++i) {
            scanf("%d", &t);
            while(t--){
                scanf("%d", &x);
                f[x].set(i);
            }
        }
        scanf("%s", s);
        int l = strlen(s);
        for (int i = 0; i < l; ++i) {
            g = g<<1;
            g.set(0);
            g &= f[s[i]-'0'];
            if(g[n-1]) {
                char tmp = s[i+1];
                s[i+1] = '';
                puts(s+i+1-n);
                s[i+1] = tmp;
            }
        }
    }
    return 0;
}

以上是关于HDU 5972 Regular Number的主要内容,如果未能解决你的问题,请参考以下文章

hdu 5972 Regular Number

hdu 5972---Regular Number(字符串匹配)

HDU 5972 Regular Number(ShiftAnd+读入优化)

HDU5972 LA7724 Regular Number位运算+字符串匹配

Regular Number hdu-5972(bitset+Shift-And算法)

Shift - And字符串快速处理 hdu5972+cf