2
  • 板块灌水区
  • 楼主2333_qwq
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/7/20 21:15
  • 上次更新2024/7/20 22:29:16
查看原帖
2
951212
2333_qwq楼主2024/7/20 21:15

P3370 WA9,10,11

#include<bits/stdc++.h>
#define base 233
#define mod1 998244353
#define mod2 1000000007
#define maxn 12345
#define maxm 1234
using namespace std;
char s[maxn][maxm];
int hsh1[maxn][maxm],hsh2[maxn][maxm],len[maxn],n,ans;
int idx(char c){
	return c-'a'+1;
}
int main(){
	cin>>n;
	for(int t=1;t<=n;t++){
		cin>>(s[t]+1);
		len[t]=strlen(s[t]+1);
		for(int i=1;i<=len[t];i++){
			hsh1[t][i]=(hsh1[t][i-1]*base+idx(s[t][i]))%mod1;
			hsh2[t][i]=(hsh2[t][i-1]*base+idx(s[t][i]))%mod2;
		}
		int flg=1;
		for(int i=1;i<t;i++)
			if(hsh1[t][len[t]]==hsh1[i][len[i]]&&hsh2[t][len[t]]==hsh2[i][len[i]])flg=0;
		if(flg)ans++;
	}
	cout<<ans<<endl;
	return 0;
}
2024/7/20 21:15
加载中...