编程语言
首页 > 编程语言> > [补漏]shift&算法

[补漏]shift&算法

作者:互联网

#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
const int M=5e6+5;
bitset<N>c[N],dp;
char s[M];
string ans;
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		int x,cc;
		scanf("%d",&cc);
		for(int j=1;j<=cc;j++) {
			scanf("%d",&x);
			c[x][i]=1;
		}
	}
	scanf("%s",s);
	for(int i=0,sz=strlen(s);i<sz;i++) {
		(dp<<=1)[0]=1;
		dp&=c[s[i]-'0'];
		if(dp[n-1]) {
			for(int j=i-n+1;j<=i;j++) {
				ans+=s[j];
			}
			ans+='\n';
		}
	}	
	printf("%s",ans.c_str());
	return 0;
}

标签:补漏,const,int,shift,每位,算法,字符串,bitsetc,dp
来源: https://www.cnblogs.com/bestime/p/15577755.html