题解 | 生词篇章查询
生词篇章查询
https://www.nowcoder.com/practice/3790042b79114ae5bd9f6eccdaeadfcd
#include <iostream>
#include <map>
#include <set>
using namespace std;
int main() {
int n;
cin>>n;
map<string,set<int>>maps;
for(int i=1;i<=n;i++){
int t;
cin>>t;
for(int j=0;j<t;j++){
string word;
cin>>word;
maps[word].insert(i);
}
}
int m;
cin>>m;
for(int i=0;i<m;i++){
string word;
cin>>word;
if(maps[word].size()!=0){
for(auto j : maps[word]){
cout<<j<<" ";
}
cout<<endl;
}
else{
cout<<endl;
}
}
return 0;
}
// 64 位输出请用 printf("%lld")
查看10道真题和解析
