QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#497805#5254. DifferencesChendaqianRE 0ms0kbC++141.1kb2024-07-29 18:12:332024-07-29 18:12:34

Judging History

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

  • [2024-07-29 18:12:34]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-29 18:12:33]
  • 提交

answer

/*
QOJ5254.cpp
Standard IO
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10,M=2e7+10;
const long long P=11451419198102353;
int n,m,k;
char ch[N];
char *s[M];
long long pw131[N],hs[N];
int main() {
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++) {
		s[i]=ch+i*(m+1);
		scanf("%s",s[i]);
		if(i==0) pw131[i]=1;
		else pw131[i]=pw131[i-1]*131%P;
	}
	// for(int i=0;i<n;i++)
	// 	fprintf(stderr,"%s\n",s[i]);
	for(int i=0;i<m;i++) {
		long long sum[4]={0},all=0;
		for(int j=0;j<n;j++) {
			all=(all+pw131[j])%P;
			sum[s[j][i]-'A']=(sum[s[j][i]-'A']+pw131[j])%P;
		}
		for(int j=0;j<n;j++) {
			hs[j]=(hs[j]+all-sum[s[j][i]-'A']+P)%P;
		}
		// cerr<<all-sum[s[3][i]-'A']<<" ";
	}
	// cerr<<"\n";
	long long mat=0;
	for(int i=0;i<n;i++) mat=((__int128)pw131[i]*k+mat)%P;
	// cerr<<mat<<"\n";
	for(int i=0;i<n;i++) 
		if(hs[i]==(mat-(__int128)pw131[i]*k%P+P)%P) {
			printf("%d",i+1);
			break;
		}
	return 0;
}
/*
cd QOJ5254
g++ QOJ5254.cpp -o QOJ5254 -std=c++14 -Wall -O2 -static "-Wl,-stack=512000000"
./QOJ5254
*/

详细

Test #1:

score: 0
Runtime Error

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: