QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#149725 | #5254. Differences | PhantomThreshold | WA | 109ms | 70044kb | C++20 | 1.4kb | 2023-08-25 13:05:37 | 2023-08-25 13:05:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll base1=97;
const ll base2=101;
const ll mod1=998244353;
const ll mod2=1'000'000'007;
const ll maxn=100000;
ll pw1[maxn+50],pw2[maxn+50];
ll sum1=0,sum2=0;
ll n,m,K;
vector<int> A[maxn+50];
ll h1[4][maxn+50],h2[4][maxn+50];
void prepare(){
pw1[0]=1;
for (int i=1;i<=maxn;i++) pw1[i]=pw1[i-1]*base1%mod1;
pw2[0]=1;
for (int i=1;i<=maxn;i++) pw2[i]=pw2[i-1]*base2%mod2;
for (int i=0;i<n;i++) sum1=(sum1+pw1[i])%mod1;
for (int i=0;i<n;i++) sum2=(sum2+pw2[i])%mod1;
}
int main(){
ios_base::sync_with_stdio(false);
cin >> n >> m >> K;
prepare();
for (int i=0;i<n;i++) A[i].resize(m+1);
// cerr << sum1 << " " << sum2 << endl;
for (int i=0;i<n;i++){
string str;
cin >> str;
for (int j=0;j<m;j++) A[i][j]=str[j]-'A';
}
for (int k=0;k<4;k++){
for (int j=0;j<m;j++){
h1[k][j]=sum1;
h2[k][j]=sum2;
}
}
for (int i=0;i<n;i++){
for (int j=0;j<m;j++){
(h1[A[i][j]][j]+=mod1-pw1[i])%=mod1;
(h2[A[i][j]][j]+=mod2-pw2[i])%=mod2;
}
}
for (int i=0;i<n;i++){
ll res1=0,res2=0;
for (int j=0;j<m;j++){
res1=(res1+h1[A[i][j]][j])%mod1;
res2=(res2+h2[A[i][j]][j])%mod2;
}
(res1+=K*pw1[i])%=mod1;
(res2+=K*pw2[i])%=mod2;
if (res1==K*sum1%mod1 && res2==K*sum2%mod2){
cout << i+1 << "\n";
return 0;
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 109ms
memory: 70044kb
input:
3585 4096 2048 ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...
output:
result:
wrong answer 1st lines differ - expected: '1397', found: ''