QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#473339#8830. Breaking BadPhantomThresholdWA 0ms3580kbC++202.6kb2024-07-12 02:02:372024-07-12 02:02:38

Judging History

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

  • [2024-07-12 02:02:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2024-07-12 02:02:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<vector<int>> a(n+5,vector<int>(n+5));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	mt19937 rng(58);
	vector<int> ok(5);
	for(int tt=1;tt<=10;tt++)
	{
		random_shuffle(a.begin()+1,a.begin()+n+1,[&](int x){return rng()%x;});
		vector<int> cp(n+5);
		for(int i=1;i<=n;i++)
			cp[i]=i;
		random_shuffle(cp.begin()+1,cp.begin()+n+1,[&](int x){return rng()%x;});
		auto b=a;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				a[i][j]=b[i][cp[j]];
		int del=0;
		for(int i=1;i<=n;i++)
		{
			int t=a[i][1];
			del+=t;
			for(int j=1;j<=n;j++)
			{
				a[i][j]-=t;
			}
		}
		for(int j=1;j<=n;j++)
		{
			int t=a[1][j];
			del+=t;
			for(int i=1;i<=n;i++)
			{
				a[i][j]-=t;
			}
		}
		sort(a.begin()+1,a.begin()+n+1);
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				swap(a[i][j],a[j][i]);
		sort(a.begin()+1,a.begin()+n+1);
		/*
		int r0=0,c0=0;
		for(int i=1;i<=n;i++)
		{
			int all0=1;
			for(int j=1;j<=n;j++)
			{
				if(a[i][j]!=0)
				{
					all0=0;
					break;
				}
			}
			if(not all0)break;
			r0=i;
		}
		for(int j=1;j<=n;j++)
		{
			int all0=1;
			for(int i=1;i<=n;i++)
			{
				if(a[i][j]!=0)
				{
					all0=0;
					break;
				}
			}
			if(not all0)break;
			c0=j;
		}
		*/
		vector<int> banr(n+5),banc(n+5);
		for(int i=1;i<=n;i++)
		{
			if(a[i]==a[i-1])
				banr[i]=banr[i-1]+1;
		}
		for(int j=1;j<=n;j++)
		{
			int chk=1;
			for(int i=1;i<=n;i++)
			{
				if(a[i][j]!=a[i-1][j])
				{
					chk=0;
					break;
				}
			}
			if(chk)
				banc[j]=banc[j-1]+1;
		}
	//	int cr=0,cc=0;
		for(int i=1;i<=n;i++)
		{
			if(banr[i]>=4)banr[i]=1;
			else banr[i]=0;
			if(banc[i]>=4)banc[i]=1;
			else banc[i]=0;
		}
		int ii=1,jj=1;
		while(ii<=n and jj<=n)
		{
			while(ii<=n and not banr[ii])ii++;
			while(jj<=n and not banc[jj])jj++;
			if(banr[ii] and banc[jj])
			{
				del+=a[ii][jj];
				ii++,jj++;
			}
		}
		while(ii<=n)banr[ii]=0,ii++;
		while(jj<=n)banc[jj]=0,jj++;
		
		vector<int> p1(n+5),p0;
		for(int i=1;i<=n;i++)
		{
			if(not banc[i])
				p0.push_back(i);
		}
		
	//	mt19937 rng(58);
		const int R=100;
		for(int tt=1;tt<=R;tt++)
		{
			random_shuffle(p0.begin(),p0.end(),[&](int x){return rng()%x;});
			int idx=0;
			for(int i=1;i<=n;i++)
			{
				if(not banr[i])
					p1[i]=p0[idx++];
			}
			int s=0;
			for(int i=1;i<=n;i++)
			{
				if(p1[i])
					s+=a[i][p1[i]];
			}
			ok[(s+del)%5]=1;
		}
	}
	for(int i=0;i<5;i++)
		cout<<"NY"[ok[i]];
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3512kb

input:

2
1 1
1 1

output:

YNYNN

result:

wrong answer 1st words differ - expected: 'NNYNN', found: 'YNYNN'