模板题,如果有误请各位大佬直接打脸,毕竟这类算法以前基本没碰过。
P.S.本题还可以用stl的set直接搞,更快更短orz。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
const int N=1e4+4;
const ull base=263;
int n;
char s[1504];
ull hs[N];
int main() {
// freopen("P3370.in","r",stdin);
memset(hs,0,sizeof(hs));
scanf("%d",&n);
for (int i=1;i<=n;++i) {
scanf("%s",s+1);
for (int j=1;s[j];++j)
hs[i]=hs[i]*base+s[j];
}
sort(hs+1,hs+n+1);
printf("%d\n",unique(hs+1,hs+n+1)-hs-1);
return 0;
}