RT
样例都过不去,从样例的反馈情况来看应该是insert函数的问题,但是我没看出来()
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll T,n,q,cnt;
ll trie[3000005][62],amount[3000005];
string s;
ll char_to_num(char x){
if('0'<=x&&x<='9')return (x-'0'+52);
else if('a'<=x&&x<='z')return (x-'a');
else return (x-'A'+26);
}
void insert(string x){
ll now=0,index;
for(char c : x){
index=char_to_num(c);
if(!trie[now][index])trie[now][index]=++cnt;
now=trie[now][index];
amount[now]++;
}
}
ll search(string x){
ll now=0,index;
for(char c : x){
index=char_to_num(c);
if(!trie[now][index])return 0;
now=trie[now][index];
}
return amount[now];
}
int main()
{
IOS;
cin>>T>>n>>q;
while(T--){
cin>>n>>q;
for(ll i=1;i<=n;i++){
cin>>s;
insert(s);
}
for(ll i=1;i<=q;i++){
cin>>s;
cout<<search(s)<<"\n";
}
for(ll i=0;i<=cnt;i++)for(ll j=0;j<62;j++)trie[i][j]=0;
for(ll i=0;i<=cnt;i++)amount[i]=0;
}
return 0;
}