/*
Author : lifehappy
*/
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const double pi = acos(-1.0);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;
inline ll read() {
ll f = 1, x = 0;
char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f * x;
}
void print(ll x) {
if(x < 10) {
putchar(x + 48);
return ;
}
print(x / 10);
putchar(x % 10 + 48);
}
const int N = 5e6 + 10;
char str[N];
int n;
vector<int> a[1010];
bitset<1010> b[10], ans;
void shift_and() {
for(int i = 0; i < 10; i++) b[i].reset();
ans.reset();
for(int i = 0; i < n; i++) {
for(int j = 0; j < a[i].size(); j++) {
b[a[i][j]].set(i);
}
}
int m = strlen(str);
for(int i = 0; i < m; i++) {
int now = str[i] - '0';
ans <<= 1;
ans.set(0);
ans = ans & b[now];
if(ans[n - 1]) {
char c = str[i + 1];
str[i + 1] = '\0';
puts(str + i + 1 - n);
str[i + 1] = c;
}
}
}
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
while(scanf("%d", &n) != EOF) {
for(int i = 0; i < n; i++) {
int num = read();
for(int j = 0; j < num; j++) {
int x = read();
a[i].pb(x);
}
}
scanf("%s", str);
// cout << str << endl;
shift_and();
for(int i = 0; i < n; i++) a[i].clear();
}
return 0;
}
HDU 5972 Regular Number(shift and 模板)
最新推荐文章于 2021-10-25 17:52:04 发布