哈希
奇怪的姿势hhh
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<ctime> 5 #include<iostream> 6 #include<algorithm> 7 #include<queue> 8 #include<set> 9 #define maxint (2147483647) 10 #define l(a) ((a)<<1) 11 #define r(a) ((a)<<1|1) 12 #define b(a) (1<<(a)) 13 #define mod1 (10000007) 14 #define mod2 (10000009) 15 #define rep(i,a,b) for(int i=a;i<=(b);i++) 16 #define clr(a) memset(a,0,sizeof(a)) 17 typedef long long ll; 18 typedef unsigned long long ull; 19 using namespace std; 20 int readint(){ 21 int t=0,f=1;char c=getchar(); 22 while(!isdigit(c)){ 23 if(c=='-') f=-1; 24 c=getchar(); 25 } 26 while(isdigit(c)){ 27 t=(t<<3)+(t<<1)+c-'0'; 28 c=getchar(); 29 } 30 return t*f; 31 } 32 const int maxn=10009,maxm=1509; 33 int n; 34 char s[maxn][maxm]; 35 int d1[maxn],d2[maxn]; 36 ull d3[maxn]; 37 int main(){ 38 //freopen("#input.txt","r",stdin); 39 //freopen("#output.txt","w",stdout); 40 n=readint(); 41 rep(i,1,n) scanf("%s",s[i]); 42 rep(i,1,n){ 43 rep(j,0,strlen(s[i])-1){ 44 d1[i]=((d1[i]*107)%mod1+s[i][j])%mod1; 45 d2[i]=((d2[i]*107)%mod2+s[i][j])%mod2; 46 d3[i]=d3[i]*107ull+s[i][j]; 47 } 48 } 49 int ans=-maxint; 50 sort(d1+1,d1+n+1);ans=max(ans,int(unique(d1,d1+n+1)-d1-1)); 51 sort(d2+1,d2+n+1);ans=max(ans,int(unique(d2,d2+n+1)-d2-1)); 52 sort(d3+1,d3+n+1);ans=max(ans,int(unique(d3,d3+n+1)-d3-1)); 53 cout<<ans<<endl; 54 //fclose(stdin); 55 //fclose(stdout); 56 return 0; 57 }