54分求调
btw为什么哈希mod的值对答案精确性影响这么大啊
#include<set>
#include<vector>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
const int N = 23333;
string s;
int ans = 0;
vector<string>linker[N+2];
void insert()
{
int hash = 1;
for (int i = 0; i < s.size(); i++)
{
hash = (hash * 111 * 261 + s[i]) % N;
}
if (linker[hash].size() == 0)
{
linker[hash].push_back(s);
ans++;
return;
}
for (int i = 0; i < linker[hash].size(); i++)
{
if (linker[hash][i] == s)
{
return;
}
linker[hash].push_back(s);
ans++;
}
}
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> s;
insert();
}
cout << ans;
return 0;
}