STL天下第一~,真的不要太方便了。字典树hash统统不存在,我只要STL
用map最后一个点会T掉,所以我们使用unordered_map
可以看到unordered_map的速度比map快很多很多。
下面是AC代码~
#include <iostream>
#include <unordered_map>
using namespace std;
#define Max 10000
unordered_map<string,int > t[Max];
int main()
{
int N,x,M;
string str;
cin>>N;
for(int i=1;i<=N;i++)
{
cin>>x;
for(int j=1;j<=x;j++)
{
cin>>str;
t[i][str]=j;
}
}
cin>>M;
for(int i=1;i<=M;i++)
{
cin>>str;
for(int j=1;j<=N;j++)
{
if(t[j].find(str)!=t[j].end())
{
cout<<j<<" ";
}
}
cout<<endl;
}
return 0;
}