#include <bits/stdc++.h>
#define f1(x , y) for(int i = x ; i <= y ; i++)
#define f2(x , y) for(int j = x ; j <= y ; j++)
#define ri register int
#define ll long long
#define il inline
#define cs const
using namespace std;
il int rd(){
int out = 0 , flag = 1; char c = getchar();
while(c < '0' || c >'9'){if(c == '-')flag = -1; c = getchar();}
while(c >= '0' && c <= '9'){out = out * 10 + c - '0'; c = getchar();}
return flag * out;
}
cs int M = 1505 , mod1 = 998244353 , mod2 = 1e9 + 7 , base = 130;
char b[M];
map <pair<ll , ll> , bool> mp;
int main(){
int n = rd() , cnt = 0;
f1(1 , n){
cin >> b + 1;
int l = strlen(b + 1);
ll hash1 = 0 , hash2 = 0;
f2(1 , l){
hash1 = (hash1 * base + b[j]) % mod1;
hash2 = (hash2 * base + b[j]) % mod2;
}pair <ll , ll> pr = make_pair(hash1 , hash2);
if(mp.find(pr) == mp.end()){
++cnt;
mp[pr] = true;
}
}cout << cnt;
return 0;
}
这个题的这里
if(mp.find(pr) == mp.end()){
++cnt;
mp[pr] = true;
}
不明白
可不可以帮忙讲一讲QwQ