QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#93623#5254. DifferencesWolamRE 0ms0kbC++141.3kb2023-04-01 22:46:452023-04-01 22:46:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-01 22:46:46]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-04-01 22:46:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,k;
const int base=19260817;
const int M1=1e9+7;
const int M2=1e9+9;
char c[10000005];
char B[4]={'A','B','C','D'};
struct ss{
	int x,y;
	ss operator *(const int ot)const{
		return (ss){x*ot%M1,y*ot%M2};
	}
	ss operator +(const ss ot)const{
		return (ss){(x+ot.x)%M1,(y+ot.y)%M2};
	}
	ss operator -(const ss ot)const{
		return (ss){(x-ot.x+M1)%M1,(y-ot.y+M2)%M2};
	}
	bool operator ==(const ss ot)const{
		return x==ot.x&&y==ot.y;
	}
}b[100005],a[100005][4],d[100005];
int num(int x,int y)
{
	return (x-1)*m+y;
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1;i<=n*m;i++)
		cin>>c[i];
	b[1]=(ss){1,1};
	d[0]=b[1]*k;
	for(int i=2;i<=n;i++)
	{
		b[i]=b[i-1]*base;
		d[0]=(d[0]+b[i]*k);
	}
	for(int i=1;i<=n;i++)
		d[i]=(d[0]-b[i]*k);
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
		{
			for(int l=0;l<4;l++)
				if(B[l]!=c[num(j,i)])
				{
					a[i][l]=a[i][l]+b[j];
				}
		}
	int x=1;
	for(int i=1;i<=n;i++)
	{
		ss t=(ss){0,0}; 
		for(int j=1;j<=m;j++)
		{
			t=t+a[j][c[num(i,j)]-'A'];
		}
	//	cerr<<d[i].x<<" "<<d[i].y<<endl;
	//	cerr<<t.x<<" "<<t.y<<endl;
		if(t==d[i])
			x=i;
	}
	cout<<x;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: