Skip to content

Instantly share code, notes, and snippets.

@takageymt
Created December 2, 2018 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takageymt/4297e823efc52ece391983f11374e1ad to your computer and use it in GitHub Desktop.
Save takageymt/4297e823efc52ece391983f11374e1ad to your computer and use it in GitHub Desktop.
#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