Created
December 2, 2018 08:08
-
-
Save takageymt/4297e823efc52ece391983f11374e1ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
char buf[5000001]; | |
int main() { | |
int N; | |
while(scanf("%d", &N) != EOF) { | |
bitset<1010> gate[10]; | |
for(int i = 0; i < N; ++i) { | |
int a; | |
cin >> a; | |
for(int j = 0; j < a; ++j) { | |
int c; | |
cin >> c; | |
gate[c][i] = 1; | |
} | |
} | |
scanf("%s", buf); | |
string s(buf); | |
bitset<1010> state; | |
for(int i = 0; i < (int)s.size(); ++i) { | |
state[0] = 1; | |
state = (state&gate[s[i]-'0']) << 1; | |
if(state[N] == 1) puts(s.substr(i-N+1, N).c_str()); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment