84分TLE求助!!!使用了unorderedmap
查看原帖
84分TLE求助!!!使用了unorderedmap
735089
ECNUAT_LZX楼主2023/7/27 18:33

#include<bits/stdc++.h>
using namespace std;
int n,q,T;
int main(){
	ios::sync_with_stdio(0);
	cin>>T;
	while(T--){
		unordered_map<string,int>mp;
		string st;
		cin>>n>>q;
		for(int i=1;i<=n;i++){
			cin>>st;
			int len=st.size();
			string ins="";
			for(int j=0;j<len;j++){
				ins+=st[j];
				mp[ins]++;
			}
		}
		for(int i=1;i<=q;i++){
			cin>>st;
			cout<<mp[st]<<endl;
		}
	}
	
	return 0;
}
2023/7/27 18:33
加载中...