RT 教练说自写清空数组比memset快,于是我
#include<bits/stdc++.h>
using namespace std;
map<string,vector<int> > a;
bool tong[100001];
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void clean(){
for(int i=1;i<=100001;i++) tong[i]=false;
}
string s;
int main(){
//std::ios::sync_with_stdio(false);
int n,l,m;
n=read();
for(int i=1;i<=n;i++){
l=read();
for(int j=1;j<=l;j++){
cin>>s;
a[s].push_back(i);
}
}
m=read();
for(int i=1; i<=m;i++)
{
cin>>s;
clean();
int len=a[s].size();
for(int j=0;j<len;j++)
if(tong[a[s][j]]==0){
cout<<a[s][j]<<" ";
tong[a[s][j]]=1;
}
puts("");
}
return 0;
}
喜提超时6个点
然后我抱着必死的决心,用了memset
memset(tong,0,sizeof(tong));
A了
所以这是怎么一回事呀?