Phoenix2010 @ 2024-09-19 21:53:37
#include<bits/stdc++.h>
using namespace std;
const int N=3e6+5;
int T,t[N][75],cnt,num[N],dfn[N];
inline void insert(string s){int rt=1;for(int i=0;i<s.size();i++) (dfn[t[rt][s[i]-'0']]==T+1?num[rt=t[rt][s[i]-'0']]++:(dfn[rt=t[rt][s[i]-'0']=++cnt]=T+1,num[rt]=1));}
inline int query(string s){int rt=1;for(int i=0;i<s.size();i++) rt=(dfn[t[rt][s[i]-'0']]==T+1)*t[rt][s[i]-'0'];return num[rt];}
int main()
{
ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
cin>>T;
while(T--)
{
int n,q;cin>>n>>q;cnt=1;
for(int i=1;i<=n;i++){string s;cin>>s;insert(s);}
while(q--){string s;cin>>s;cout<<query(s)<<"\n";}
}
return 0;
}
by Phoenix2010 @ 2024-09-19 21:58:50
提交记录
by FugiPig @ 2024-09-20 00:48:09
多测不清空, 爆零两行泪.
by FugiPig @ 2024-09-20 00:58:47
@FugiPig 哦我看错了(
by FugiPig @ 2024-09-20 01:02:01
t
数组应该这样定义:int t[N][76]
by Phoenix2010 @ 2024-09-20 15:26:57
@FugiPig 这个数组大小肯定够,而且改了之后还是过不了……
by mooktian @ 2024-10-10 11:08:53
@FugiPig t数组开到62就够了。
by Phoenix2010 @ 2024-11-08 21:33:25
终于调出来了,警示一下后人