字符串算法都好难啊……
1. 字符串哈希
#define int long long
int n,cnt,finalans;
int mod1=1e9+7,base=107,mod2=1e9+9;
struct node{int x,y;}a[10010];
bool cmp(node a,node b)
{
if(a.x!=b.x)return a.x<b.x;
return a.y<b.y;
}
int hash1(string s)
{
int ans=0,l=s.length();
for(int i=0;i<l;i++)ans=(ans*base%mod1+(s[i]-'0'+1))%mod1;
return ans;
}
int hash2(string s)
{
int ans=0,l=s.length();
for(int i=0;i<l;i++)ans=(ans*base%mod2+(s[i]-'0'+1))%mod2;
return ans;
}
signed main()
{
//...
for(int i=1;i<=n;i++)
{
string s;cin >> s;
a[++cnt].x=hash1(s);
a[cnt].y=hash2(s);
}
finalans=n;
sort(a,a+n+1,cmp);
for(int i=1;i<n;i++)
if(a[i].x==a[i+1].x||a[i].y==a[i+1].y)
finalans--;
cout << finalans;
return 0;
}