QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#149723#5254. DifferencesPhantomThresholdWA 111ms69904kbC++201.4kb2023-08-25 13:03:112023-08-25 13:03:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-25 13:03:13]
  • 评测
  • 测评结果:WA
  • 用时:111ms
  • 内存:69904kb
  • [2023-08-25 13:03:11]
  • 提交

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: 111ms
memory: 69904kb

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result:

wrong answer 1st lines differ - expected: '1397', found: ''