标签:span etc turn pre getch 难度 tchar cin vector
不可否认,\(TJOI\)的这道题确实不难
为本题写博客的唯一原因就是
\(STL\)大法好!!!!
不简述题意了,因为实在是简单
直接\(map<string,vector<int> > mp\),后面的\(vector\)统计答案就完事了
码量小,思维难度小,何乐不为?
#include <bits/stdc++.h>
using namespace std;
#define int long long
namespace yspm {
map<string, vector<int> > mp;
inline int read() {
int res = 0, f = 1;
char k;
while (!isdigit(k = getchar()))
if (k == '-')
f = -1;
while (isdigit(k)) res = res * 10 + k - '0', k = getchar();
return res * f;
}
string s;
int tmp, n, sz;
bool vis[10010];
signed main() {
n = read();
for (int i = 1; i <= n; ++i) {
tmp = read();
while (tmp--) cin >> s, mp[s].push_back(i);
}
vector<int> vec;
n = read();
for (int i = 1; i <= n; ++i) {
cin >> s;
if (!mp.count(s)) {
puts("");
continue;
}
memset(vis, 0, sizeof(vis));
vec = mp[s];
sz = vec.size();
for (int j = 0; j < sz; ++j)
if (!vis[vec[j]])
printf("%lld ", vec[j]), vis[vec[j]] = 1;
puts("");
}
return 0;
}
} // namespace yspm
signed main() { return yspm::main(); }
标签:span etc turn pre getch 难度 tchar cin vector
原文地址:https://www.cnblogs.com/yspm/p/12350019.html