You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
978 B
40 lines
978 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int n, m, cnt;
|
|
int flag[500000];
|
|
unordered_map<string, int> match;
|
|
vector<int> G[100010];
|
|
|
|
int main() {
|
|
cin >> n;
|
|
for (int i = 1; i <= n; i++) {
|
|
int opt;
|
|
cin >> opt;
|
|
for (int j = 1; j <= opt; j++) {
|
|
string op;
|
|
cin >> op;
|
|
if (!match[op]) {
|
|
cnt++;
|
|
match[op] = cnt;//映射成数字
|
|
G[cnt].push_back(i);
|
|
} else {
|
|
G[match[op]].push_back(i);
|
|
}
|
|
}
|
|
}
|
|
cin >> m;
|
|
for (int i = 1; i <= m; i++) {
|
|
string opt;
|
|
cin >> opt;
|
|
memset(flag, 0, sizeof(flag));
|
|
for (int j = 0; j < G[match[opt]].size(); j++) {
|
|
if (flag[G[match[opt]][j]])continue;//判重
|
|
flag[G[match[opt]][j]] = 1;
|
|
cout << G[match[opt]][j] << ' ';
|
|
}
|
|
cout << '\n';
|
|
}
|
|
return 0;
|
|
}
|