- 【模板】字典树 1
【求调】set为什么TLE50
- 2025-2-2 10:59:33 @
#include<iostream>
#include<set>
#include<cstdio>
#include<string.h>
using namespace std;
set<string> st;
string read(){
char c;
string ans="";
while(1){
scanf("%c",&c);
if(c>='a'&&c<='z'){
ans+=c;
break;
}
}
while(1){
scanf("%c",&c);
if(c>='a'&&c<='z'){
ans+=c;
}
else break;
}
return ans;
}
int n;
int main(){
scanf("%d" ,&n);
while(n--){
string str;
str=read();
st.insert(str);
}
printf("%d",st.size());
}
求调
1 条评论
-
wuyiming1263 LV 2 @ 2025-2-4 10:55:36
set 的时间复杂度带了个 log,自己不先算算吗。。。
- 1
信息
- ID
- 180
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 3
- 标签
- 递交数
- 2963
- 已通过
- 396
- 上传者