理论上时间复杂度最低的算法!!!
2025-03-30 17:34:22
发布于:广东
35阅读
0回复
0点赞
#include <iostream>
#include <cstdio>
#include <unordered_map>
using namespace std;
const int C = 131;
unordered_map <unsigned long long, int> mp;
int main(){
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
while(n--){
string s;
cin >> s;
unsigned long long HASH = 0;
for(char c:s){
HASH = HASH * C + c;
}
cout << s;
if(mp[HASH]) cout << '(' << mp[HASH] << ')';
cout << '\n';
mp[HASH]++;
}
return 0;
}
时间复杂度:
不过能被设计蚂蚁
这里空空如也
有帮助,赞一个