QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#378517#8566. Can We Still Qualify For Semifinals?ucup-team052#WA 15ms3844kbC++231.2kb2024-04-06 13:20:322024-04-06 13:20:32

Judging History

This is the latest submission verdict.

  • [2024-04-06 13:20:32]
  • Judged
  • Verdict: WA
  • Time: 15ms
  • Memory: 3844kb
  • [2024-04-06 13:20:32]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define N 55
char s[N];
int a[N];
int n,m=10;
int mat[N][2],p[N],win[N],cnt;
void work()
{
	cin>>n; scanf("%s",s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'0';
	if(n<=20) printf("YES\n");
	else
	{
		int ned=0;
		for(int j=n+1;j<=cnt;j++) if(j%5!=1) ned++;
		for(int j=0;j<1<<ned;j++)
		{
			int tw=0;
			for(int i=n+1;i<=cnt;i++)
			{
				if(i%5==1) a[i]=1;
				else a[i]=j>>(tw++)&1;
			}
			for(int i=1;i<=m;i++) win[i]=0;
			for(int i=1;i<=cnt;i++)
			{
				if(a[i]) win[mat[i][0]]++;
				else win[mat[i][1]]++;
			}
			int bad=0;
			for(int i=2;i<=m;i++) if(win[i]>win[1]) bad++;
			if(bad<=3)
			{
				printf("YES\n");
				return ;
			}
		}
		printf("NO\n");
	}
}
signed main()
{
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	for(int i=1;i<=m;i++) p[i]=i;
	auto ins=[&]()
	{
		for(int i=1;i<=5;i++)
		{
			cnt++;
			mat[cnt][0]=p[i],mat[cnt][1]=p[m-i+1];
		}
	};
	ins();
	for(int i=1;i<=9;i++)
	{
		int t=p[m];
		for(int j=m;j>2;j--) p[j]=p[j-1];
		p[2]=t;
		ins();
	}
//	for(int i=1;i<=cnt;i++) printf("%d %d\n",mat[i][0],mat[i][1]);
	int T; cin>>T;
	while(T--) work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3
111
25
1000010101111111111010100
35
01111011110111101111011110111101111

output:

YES
YES
NO

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

10
16
0110000001010100
17
01111000110110101
15
001100010101111
16
0010101010011100
19
0000000100010110100
16
0011101010011100
18
011110010001100000
18
000110101001100011
20
01100010000100100100
15
001000111001101

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 10 token(s): yes count is 10, no count is 0

Test #3:

score: -100
Wrong Answer
time: 15ms
memory: 3812kb

input:

10
37
0110000001010100011101001011100110001
39
000100111101101001100101101000000000100
35
00111000100111100101011010111100100
33
010000010001110010110001101110001
30
000100010100000010010110101010
31
0000101000011010101001010000000
44
00001000000111101011010110000101100011000100
42
01111011110001001...

output:

NO
NO
NO
NO
YES
NO
NO
NO
NO
NO

result:

wrong answer expected NO, found YES [5th token]