社区讨论
60pts求条
P4503[CTSC2014] 企鹅 QQ参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @m40y3k10
- 此快照首次捕获于
- 2024/11/28 14:40 去年
- 此快照最后确认于
- 2025/11/04 13:45 4 个月前
rt
CPP#include <bits/stdc++.h>
using namespace std;
int n,l,s;
string ss[300005];
int bs=1145,mod=10114523;
int pw[300005];
int hush[300005][205];
int hs[300005];
long long ans=0;
int main(){
// freopen("test.in","r",stdin);
// freopen("test.out","w",stdout);
cin>>n>>l>>s;
for (int i=1;i<=n;i++){
cin>>ss[i];
}
pw[0]=1;
for (int i=1;i<=l;i++){
pw[i]=pw[i-1]*bs;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=l;j++){
hush[i][j]=(hush[i][j-1]*bs+ss[i][j-1])%mod;
}
}
for (int i=1;i<=l;i++){
for (int j=1;j<=n;j++){
hs[j]=(hush[j][i-1]*pw[l-i]+hush[j][l]-hush[j][i]*pw[l-i])%mod;
}
sort(hs+1,hs+n+1);
int tt=1;
for (int j=1;j<=n;j++){
if (hs[j]!=hs[j-1]){
tt=1;
}
else{
ans+=tt;
tt++;
}
}
}
cout<<ans<<endl;
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...