社区讨论
用map也能卡过
P8306【模板】字典树参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lyjgfcw9
- 此快照首次捕获于
- 2024/07/13 09:34 2 年前
- 此快照最后确认于
- 2024/07/13 10:50 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
string s,ll;
int n,m,maxn,t;
map<string,int> p;
int main(){
cin>>t;
while(t--){
p.clear();
scanf("%d%d",&n,&m);
getchar();
string s="";
int sum=0;
while(1){
char ch=getchar();
if(ch=='\n'){
s="";
sum++;
if(sum==n){
break;
}
}else{
s+=ch;
p[s]++;
}
}
while(m--){
string ll="";
char ch=getchar();
while(ch!='\n'){
ll+=ch;
ch=getchar();
}
cout<<p[ll]<<"\n";
}
}
return 0;
}
但是
unordered_map会被卡成 。回复
共 3 条回复,欢迎继续交流。
正在加载回复...