QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#473333#8830. Breaking BadPhantomThresholdWA 614ms11620kbC++202.5kb2024-07-12 01:59:352024-07-12 01:59:36

Judging History

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

  • [2024-07-12 01:59:36]
  • 评测
  • 测评结果:WA
  • 用时:614ms
  • 内存:11620kb
  • [2024-07-12 01:59:35]
  • 提交

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);
	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=100000;
	vector<int> ok(5);
	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: 2ms
memory: 3568kb

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

2
1 1
1 1

output:

NNYNN

result:

ok "NNYNN"

Test #3:

score: 0
Accepted
time: 4ms
memory: 3548kb

input:

4
0 0 1 0
0 1 0 1
0 0 0 0
1 1 0 0

output:

YYYYN

result:

ok "YYYYN"

Test #4:

score: 0
Accepted
time: 4ms
memory: 3632kb

input:

4
0 0 0 1
0 1 0 1
1 0 0 0
0 1 0 0

output:

YYYYN

result:

ok "YYYYN"

Test #5:

score: 0
Accepted
time: 9ms
memory: 3572kb

input:

10
1 4 2 0 0 2 0 1 3 3
0 3 1 4 4 1 4 0 2 2
1 4 2 0 0 2 0 1 0 3
0 3 1 4 4 1 4 0 2 2
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
1 4 2 0 0 2 0 1 3 3
3 1 4 2 2 4 2 3 0 0

output:

NYNNY

result:

ok "NYNNY"

Test #6:

score: 0
Accepted
time: 9ms
memory: 3584kb

input:

10
4 4 4 1 3 4 1 4 3 0
3 3 3 0 2 3 0 3 2 4
3 3 3 0 2 3 0 3 2 4
4 4 4 1 3 4 1 4 3 0
2 2 2 4 1 2 4 2 1 3
2 2 2 4 1 3 4 2 1 3
4 4 4 1 3 4 1 4 3 0
3 3 3 0 2 3 0 3 2 4
2 2 2 4 1 2 4 2 1 3
4 4 4 1 3 4 1 1 3 0

output:

YYYNY

result:

ok "YYYNY"

Test #7:

score: 0
Accepted
time: 9ms
memory: 3628kb

input:

10
1 2 0 4 2 3 4 0 2 3
0 1 4 3 1 2 3 4 1 2
4 0 3 2 0 1 2 3 0 1
1 2 0 4 2 3 4 0 2 3
3 4 2 1 4 0 1 2 4 0
0 1 4 3 1 2 3 4 1 2
2 3 1 0 3 4 0 1 3 4
3 1 1 1 4 0 1 2 4 0
1 2 0 4 2 3 4 0 2 3
1 3 0 4 2 3 4 0 2 3

output:

NYYYY

result:

ok "NYYYY"

Test #8:

score: 0
Accepted
time: 9ms
memory: 3868kb

input:

10
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4
2 3 4 2 1 1 4 3 4 1
0 1 2 0 4 4 2 1 2 4
0 1 2 0 4 4 2 1 2 4
0 1 2 0 4 4 2 1 2 4
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4

output:

NYNNN

result:

ok "NYNNN"

Test #9:

score: 0
Accepted
time: 9ms
memory: 3608kb

input:

10
4 1 3 1 2 0 3 2 4 4
0 2 4 2 3 1 4 3 0 0
1 1 1 1 2 0 3 2 4 1
2 4 1 4 0 3 1 0 2 2
1 3 0 3 4 2 0 4 1 1
2 4 1 4 0 3 1 0 2 2
2 4 1 4 0 3 1 0 2 2
0 2 4 2 3 1 4 3 0 0
3 0 2 1 1 4 2 1 3 3
4 1 3 1 2 0 3 2 4 4

output:

YYYYY

result:

ok "YYYYY"

Test #10:

score: 0
Accepted
time: 9ms
memory: 3808kb

input:

10
1 2 0 2 4 2 3 1 2 1
4 0 3 0 2 0 1 4 0 4
0 1 4 1 3 1 2 0 1 0
0 1 4 1 3 1 2 0 1 0
3 4 2 4 1 4 0 3 4 3
4 0 3 0 2 0 1 4 0 4
0 1 4 1 3 1 2 0 1 0
0 1 4 1 3 1 2 0 1 0
3 4 2 4 1 4 0 3 4 3
0 1 4 1 3 1 2 0 1 0

output:

NNNYN

result:

ok "NNNYN"

Test #11:

score: 0
Accepted
time: 9ms
memory: 3868kb

input:

10
1 4 1 2 1 3 3 2 1 2
0 3 0 1 0 2 2 1 0 1
0 4 0 3 0 2 2 1 0 1
1 4 1 2 1 3 3 2 1 2
4 2 4 0 4 1 1 0 4 0
1 1 1 4 1 0 3 2 1 2
0 0 0 1 0 2 2 1 0 1
2 0 2 3 2 4 4 3 2 3
2 0 2 3 2 4 4 3 2 3
2 0 2 3 2 4 4 3 2 3

output:

YYYYY

result:

ok "YYYYY"

Test #12:

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

input:

10
1 2 0 1 4 0 1 2 2 2
1 2 0 1 4 3 1 2 2 2
0 1 4 0 3 1 0 1 1 1
1 2 0 1 4 3 1 2 2 2
3 4 2 3 1 4 3 4 4 4
0 1 4 0 3 1 0 1 1 1
4 0 3 4 2 0 4 0 0 0
3 4 2 3 1 4 3 4 4 4
4 0 3 4 2 0 4 0 0 0
0 1 4 0 3 1 0 1 1 1

output:

YNYNY

result:

ok "YNYNY"

Test #13:

score: 0
Accepted
time: 9ms
memory: 3568kb

input:

10
1 3 0 0 2 1 3 4 3 3
3 3 0 0 4 1 3 4 3 3
1 1 3 3 2 4 1 2 1 1
2 4 1 1 3 2 4 0 4 4
4 1 3 3 0 4 1 2 1 1
2 4 1 1 3 2 4 0 4 4
0 2 4 4 1 0 2 3 2 2
3 0 2 2 4 3 0 1 0 0
3 0 2 2 4 3 0 1 0 0
4 2 4 4 1 0 2 3 2 2

output:

YYYNY

result:

ok "YYYNY"

Test #14:

score: 0
Accepted
time: 6ms
memory: 3672kb

input:

10
2 0 3 1 3 0 0 0 4 1
1 4 2 0 2 4 4 4 3 0
2 0 3 1 3 0 0 0 4 1
1 4 2 0 2 4 4 4 3 0
1 4 2 0 2 4 4 4 3 0
3 3 4 2 4 1 1 1 0 2
3 1 4 2 4 1 1 1 0 2
4 2 0 3 0 2 2 2 1 3
3 1 4 2 4 1 1 1 0 2
1 4 2 0 2 4 4 4 3 0

output:

YNYNN

result:

ok "YNYNN"

Test #15:

score: 0
Accepted
time: 614ms
memory: 11560kb

input:

1000
3 4 1 2 4 1 0 3 0 4 1 4 3 1 4 4 1 0 1 2 3 1 0 1 3 4 4 0 3 0 3 2 2 1 0 4 1 3 3 0 3 1 3 2 2 0 3 3 2 2 3 0 4 2 1 2 1 2 1 4 2 4 1 4 2 4 3 2 0 3 0 4 2 1 2 3 3 0 2 0 3 3 1 1 0 3 4 3 2 0 4 0 3 4 4 2 3 4 2 3 4 2 1 3 2 2 4 1 0 2 2 4 0 1 2 0 4 1 3 2 3 2 2 2 1 4 4 4 2 0 0 4 4 1 3 4 0 2 2 3 1 1 3 2 3 2 3 0...

output:

NNNYN

result:

ok "NNNYN"

Test #16:

score: -100
Wrong Answer
time: 569ms
memory: 11620kb

input:

1000
2 3 0 1 0 0 0 1 1 4 1 4 2 3 0 3 4 2 3 2 4 2 1 1 1 1 0 0 3 3 2 0 2 2 2 4 3 0 3 3 3 0 1 3 0 2 0 1 0 0 0 3 1 4 3 1 4 0 3 4 4 1 3 3 4 0 1 4 2 3 0 1 0 0 2 3 1 4 0 0 2 1 2 3 3 4 4 3 3 2 0 0 4 3 2 3 3 2 4 0 2 2 3 0 3 2 4 1 0 2 4 2 4 1 2 1 3 0 3 3 0 1 1 0 2 3 0 2 4 1 4 3 4 1 2 2 2 4 0 1 3 3 0 0 1 3 2 4...

output:

NYNYY

result:

wrong answer 1st words differ - expected: 'NYYYY', found: 'NYNYY'