rt.本蒟蒻判重也判过了,但还是找不出错哪里。有哪位大佬帮我看一下吗?
#include <bits/stdc++.h>
using namespace std;
string str,str1;
struct s{
unsigned long long cnt;
int id;
}a[5000005];
int main(){
int n;
cin>>n;
int ans=0;
for(int i=1;i<=n;i++){
int l;
cin>>l;
for(int j=1;j<=l;j++){
cin>>str;
a[ans].cnt=0;
for(int o=0;o<str.length();o++){
a[ans].cnt=a[ans].cnt*131+(unsigned long long)(str[o]);
}
a[ans].id=i;
ans++;
}
}
int m;
cin>>m;
for(int i=1;i<=m;i++){
cin>>str1;
unsigned long long sum=0;
for(int j=0;j<str1.length();j++){
sum=sum*131+(unsigned long long)(str1[j]);
}
bool b=0;
for(int j=0;j<ans;j++){
if(sum==a[j].cnt&&b!=a[j].id){
cout<<a[j].id<<" ";
b=a[j].id;
}
}
cout<<endl;
}
return 0;
}