QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190166 | #6851. Cyclically Isomorphic | masterhuang | WA | 25ms | 34928kb | C++20 | 1.0kb | 2023-09-28 14:00:22 | 2023-09-28 14:00:23 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
inline string rds()
{
string x="";char ch=getchar();
while(ch<'a'||ch>'z') ch=getchar();
while(ch>='a'&&ch<='z') x+=ch,ch=getchar();
return x;
}
inline int rd()
{
int x=0;char ch=getchar();
while(ch<'0'||ch>'9') ch=getchar();
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x;
}
const int N=1e6+5,mod=998244353;
int T,n,m,q,pw[N],a[N];string c[N];
inline int md(int x){return x>=mod?x-mod:x;}
int main()
{
T=rd();
while(T--)
{
n=rd(),m=rd();for(int i=1;i<=n;i++) c[i]=rds();q=rd();
for(int i=pw[0]=1;i<=m;i++) pw[i]=28ll*pw[i-1]%mod;
for(int i=1;i<=n;i++)
{
int S=0;
for(int j=0;j<m;j++) S=(S+1ll*pw[m-1-j]*(c[i][j]-'a'+1))%mod;a[i]=S;
for(int j=0;j<m-1;j++) S=md((S-1ll*pw[m-1]*(c[i][j]-'a'+1))%mod+mod),
a[i]=min((LL)a[i],(28ll*S+(c[i][j]-'a'+1))%mod);
}int x,y;
while(q--) x=rd(),y=rd(),puts((a[x]==a[y])?"Yes":"No");
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 25ms
memory: 34928kb
input:
5 10 10000 afcadffafeeebdfedfdafecfdbeecbcadfedcffaedecbacffedeccacfcbfbbdbcefbdefefebcbeacfbaafddbabcbfaeddaaefebbddafaaaaaedcbbdaafaffcbeeebfbbeedebabfbdbaceabfcccfedbdeafccbaffdeadbefbfeadbbedeeabbaafebaceeaeedbaddfecdefaabdbcfadadaebbdeedcfeeabbbdbcefdadbeecafcabbddddbcacadbbcddeddbbeecbdadefbaa...
output:
No No No Yes Yes No No No Yes No No No No No No No No No No No No No Yes No No No No No No No No No No Yes No No No Yes No No No No No No No No Yes No Yes No No No No No Yes No No No No No No No No No Yes No No Yes No No No No No No No No No No No Yes No Yes No Yes No No No No No No No No Yes Yes Ye...
result:
wrong answer 100005th lines differ - expected: 'Yes', found: 'No'