You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
const int K = 130; //一个大于128的数字
|
|
|
|
|
const int MOD = 23333; //素数常数
|
|
|
|
|
int n; //字符串个数
|
|
|
|
|
int ans; //结果
|
|
|
|
|
string s; //字符串
|
|
|
|
|
|
|
|
|
|
// 链表
|
|
|
|
|
vector<string> linker[MOD + 10];
|
|
|
|
|
|
|
|
|
|
void insert(string t) {
|
|
|
|
|
//计算字符串t的HASH值
|
|
|
|
|
int hash = 1;
|
|
|
|
|
for (int i = 0; s[i]; i++) hash = (hash * K + s[i]) % MOD;
|
|
|
|
|
|
|
|
|
|
//找到HASH链表,逐个排查,存在,则结果不+1,否则+1
|
|
|
|
|
for (int i = 0; i < linker[hash].size(); i++)
|
|
|
|
|
if (linker[hash][i] == t) return;
|
|
|
|
|
//放入链表
|
|
|
|
|
linker[hash].push_back(t);
|
|
|
|
|
//结果+1
|
|
|
|
|
ans++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
cin >> n;
|
|
|
|
|
for (int i = 1; i <= n; i++) cin >> s, insert(s);
|
|
|
|
|
cout << ans << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|