QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#60735#4797. XormitesCrysflyWA 2ms3500kbC++171.4kb2022-11-06 22:28:472022-11-06 22:55:05

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-06 22:55:05]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3500kb
  • [2022-11-06 22:28:47]
  • 提交

answer

// 互测原题 /jy

// what is matter? never mind.
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first 
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

int n,a[maxn],xsum,b[maxn];

bool ok(int l,int r)
{
	for(int i=l;i<=r;i+=2)
		if(b[i]!=b[i+1])return 0;
	return 1;
}
bool chk(int l,int r)
{
	assert((r-l+1)%2==0);
	if(l>r)return 1;
	int i=l,j=r;
	while(i<=j && b[i]==b[j])++i,--j;
	if(i>j)return 1;
	if(ok(i,j))return 1;
	if(i-1>=l && ok(i-1,j+1))return 1;
	return 0;
}

void work()
{
	n=read(),xsum=0;
	For(i,1,n)a[i]=read(),xsum^=a[i];
	if(!xsum){
		puts("Draw");
		return;
	}
	int bt=0;
	Rep(i,30,0)if(xsum>>i&1)bt=i;
	For(i,1,n)b[i]=(a[i]>>bt&1);
	if(n%2==0){
		puts("First");
		return;
	}
	int sum=accumulate(b+1,b+n+1,0);
	int s1=sum/2+1,s2=sum/2;
	if(s1%2==0){
		puts("Second");
		return;
	}
	if((b[1]&&chk(2,n)) || (b[n]&&chk(1,n-1))){
		puts("First");
		return;
	}
	puts("Second");
}

signed main()
{
	int T=read();
	while(T--)work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3340kb

input:

3
2
3 3
2
3 5
3
4 4 4

output:

Draw
First
Second

result:

ok 3 lines

Test #2:

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

input:

12
10
1 3 1 3 3 3 2 1 3 3
10
1 3 3 3 1 3 2 1 1 3
9
1 2 3 3 3 1 2 2 3
9
1 3 2 1 3 3 2 2 2
10
3 2 2 2 3 3 1 2 1 2
10
2 1 2 3 3 3 3 2 3 2
10
2 1 1 3 3 1 1 1 2 1
10
2 1 1 1 1 1 1 2 2 3
10
2 1 2 1 1 2 2 3 3 3
9
2 2 1 1 3 3 1 2 3
9
1 3 3 2 2 2 2 3 2
10
1 1 1 1 1 2 2 2 1 2

output:

First
First
Second
Second
First
First
Draw
First
First
Draw
Draw
Draw

result:

ok 12 lines

Test #3:

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

input:

12
9
3 4 1 5 2 1 5 3 1
10
6 2 4 5 4 2 5 7 5 6
9
5 3 2 1 2 4 4 1 4
9
5 7 6 2 7 2 5 7 4
10
7 5 1 6 7 1 5 1 4 5
10
4 2 6 2 7 2 2 2 3 5
10
7 3 4 7 4 4 2 3 7 5
9
3 3 7 1 6 3 7 2 3
10
5 3 7 7 2 6 4 7 3 1
10
1 7 4 2 4 2 6 6 4 4
10
4 1 3 4 4 4 5 4 1 7
9
4 3 4 7 1 6 2 2 5

output:

Second
First
Second
Second
First
First
First
Second
First
First
First
Second

result:

ok 12 lines

Test #4:

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

input:

12
9
1 5 7 1 4 7 7 3 1
9
2 7 3 2 1 5 1 6 6
10
3 4 6 6 4 5 4 7 5 4
9
2 3 1 5 7 3 6 3 3
10
1 2 5 2 2 6 3 7 7 3
9
2 3 1 1 5 5 2 6 2
9
6 6 4 1 5 4 6 1 2
10
2 6 2 3 6 7 7 4 2 5
10
3 4 5 5 2 1 1 2 4 1
9
7 5 5 2 3 7 7 1 1
10
7 1 3 7 3 4 4 1 7 5
10
2 6 5 7 3 6 1 3 3 3

output:

Second
Second
First
Second
Draw
Second
Second
Draw
First
First
First
First

result:

ok 12 lines

Test #5:

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

input:

12
10
1 1 1 2 1 2 1 1 1 2
10
1 1 1 2 1 1 2 1 1 2
10
1 2 2 1 2 1 1 1 2 1
10
2 2 2 1 2 2 1 2 2 2
10
1 1 1 2 1 1 2 2 2 1
10
2 2 1 2 1 1 2 1 1 2
10
2 2 1 2 1 1 1 1 1 2
10
2 2 1 2 1 1 1 2 2 2
10
2 1 1 1 1 1 2 1 2 2
10
2 1 2 1 2 1 1 2 2 2
10
2 1 1 1 1 1 2 1 1 1
15
913276852 922705701 913276910 914316078 2...

output:

First
First
Draw
Draw
Draw
First
Draw
Draw
Draw
Draw
Draw
Second

result:

ok 12 lines

Test #6:

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

input:

12
10
2 2 1 1 1 2 2 2 1 2
10
1 1 1 2 1 2 2 1 1 2
10
2 1 2 1 2 2 1 2 2 2
10
1 1 2 1 2 1 2 1 1 2
10
2 2 1 2 1 2 2 1 1 2
10
2 2 1 1 1 2 1 1 1 1
10
1 2 1 2 1 1 1 2 1 2
10
2 1 1 1 2 2 2 1 1 1
10
1 1 1 2 1 2 2 2 2 1
10
1 2 1 1 1 2 1 2 1 1
10
2 2 1 2 1 2 2 1 1 2
10
1 1 2 2 2 2 2 1 2 1

output:

Draw
Draw
First
Draw
Draw
First
Draw
Draw
First
First
Draw
Draw

result:

ok 12 lines

Test #7:

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

input:

12
10
2 1 1 1 1 2 2 1 2 2
10
2 1 2 2 2 1 1 2 2 1
10
1 1 1 2 2 2 2 1 1 1
10
1 1 1 2 1 1 2 2 1 1
10
1 2 2 2 2 1 2 2 2 2
10
2 1 1 2 2 2 1 1 2 2
10
1 2 2 2 1 1 1 2 1 1
10
1 1 2 1 1 1 1 1 1 2
10
2 1 1 1 1 1 1 1 2 1
10
2 2 1 2 2 1 1 1 1 1
10
1 2 2 1 1 1 2 1 1 2
10
2 1 1 2 1 2 1 2 1 1

output:

First
Draw
Draw
First
Draw
Draw
Draw
Draw
Draw
Draw
Draw
Draw

result:

ok 12 lines

Test #8:

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

input:

12
10
1 2 1 1 1 2 1 2 2 2
10
2 2 2 1 2 1 1 2 2 2
10
2 1 1 2 1 2 2 1 1 2
10
1 1 1 2 1 1 1 1 1 1
10
2 2 2 1 2 2 1 2 2 2
10
1 1 1 2 2 1 2 2 1 2
10
2 2 1 2 1 1 1 2 2 1
10
2 2 1 2 1 2 1 1 1 1
10
2 2 2 1 1 2 1 1 2 1
10
2 2 1 2 1 2 1 2 1 2
10
1 1 1 2 2 1 1 2 1 1
10
2 2 2 1 1 2 1 1 1 2

output:

First
First
First
First
Draw
First
First
Draw
First
Draw
First
First

result:

ok 12 lines

Test #9:

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

input:

12
10
1 2 2 1 2 1 1 1 1 2
10
1 2 2 2 1 1 1 1 2 2
10
2 2 1 2 1 1 2 2 2 1
10
2 1 1 2 1 1 2 1 2 1
10
1 1 1 1 1 1 2 1 1 1
10
2 2 2 2 2 2 2 1 2 1
10
2 1 2 2 1 2 2 2 1 2
10
2 2 2 1 1 2 1 2 1 1
10
2 1 1 1 1 2 1 1 1 1
10
1 1 1 2 2 1 2 1 1 1
10
2 1 1 2 2 1 1 2 1 1
10
2 2 2 2 1 2 1 1 2 1

output:

Draw
First
Draw
Draw
First
Draw
First
First
Draw
First
Draw
Draw

result:

ok 12 lines

Test #10:

score: 0
Accepted
time: 1ms
memory: 3336kb

input:

12
10
2 1 1 1 1 1 2 1 1 1
10
1 1 1 2 1 1 2 2 1 1
10
1 1 1 1 2 2 2 1 1 1
10
1 2 1 1 1 2 1 1 2 1
10
1 2 2 2 2 2 2 2 2 1
10
1 1 1 2 1 2 1 2 2 2
10
1 2 1 2 2 1 1 1 2 2
10
2 2 1 2 1 2 2 1 2 1
10
1 1 1 2 2 2 1 1 2 1
10
2 1 1 1 1 2 1 2 1 1
10
1 2 2 1 2 2 1 1 2 1
10
1 1 1 1 1 2 2 2 1 2

output:

Draw
First
First
First
Draw
First
First
Draw
Draw
First
First
Draw

result:

ok 12 lines

Test #11:

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

input:

12
10
3 3 1 2 3 2 3 1 3 3
10
1 1 1 2 1 3 3 3 3 2
10
2 2 2 3 2 2 2 3 1 3
10
3 1 2 3 2 3 3 2 1 3
10
2 3 3 3 3 3 3 1 1 1
10
1 2 1 1 3 3 2 3 3 3
10
3 3 1 2 3 3 1 1 2 2
10
1 2 3 3 1 2 1 1 1 1
10
2 1 1 1 2 1 2 3 1 1
10
1 3 2 2 2 1 1 2 2 3
10
3 1 1 3 1 2 1 3 2 3
10
3 2 1 1 2 1 3 1 3 1

output:

Draw
Draw
First
First
First
First
First
Draw
First
First
Draw
First

result:

ok 12 lines

Test #12:

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

input:

12
10
3 3 1 2 1 2 1 1 3 2
10
2 1 1 2 1 1 3 2 3 3
10
1 1 2 3 3 3 2 2 3 3
10
2 3 2 3 1 2 1 2 1 3
10
2 3 2 2 1 1 2 2 2 3
10
1 2 2 3 3 3 1 2 2 1
10
2 3 3 1 1 1 3 1 2 1
10
2 2 3 2 2 1 1 2 2 1
10
3 2 2 1 1 1 1 1 3 1
10
1 3 1 2 2 2 1 1 1 3
10
3 2 1 1 3 3 1 1 3 1
10
3 2 3 1 1 3 1 1 1 2

output:

First
First
First
First
Draw
First
First
First
Draw
First
First
First

result:

ok 12 lines

Test #13:

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

input:

12
10
3 2 3 2 3 3 3 3 1 3
10
2 3 3 3 1 2 3 2 1 2
10
3 3 3 2 1 1 1 3 1 3
10
3 2 2 3 1 2 1 3 3 2
10
3 2 3 3 2 2 1 2 3 2
10
1 3 2 2 3 1 3 3 2 2
10
1 3 2 3 2 3 3 1 3 2
10
2 2 3 3 3 2 3 1 2 3
10
2 3 3 3 1 2 2 1 3 2
10
2 2 1 2 1 1 2 2 1 2
10
2 1 1 3 2 2 2 3 3 3
10
2 2 3 2 2 1 1 1 1 1

output:

First
Draw
First
Draw
First
Draw
First
First
Draw
Draw
Draw
First

result:

ok 12 lines

Test #14:

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

input:

12
9
1 3 2 1 1 2 2 1 3
9
1 1 1 3 2 2 2 1 2
9
1 3 1 3 1 2 2 1 2
9
3 3 3 1 1 1 2 3 2
9
2 1 2 1 2 1 1 3 1
9
1 2 2 1 2 1 3 3 2
9
2 2 3 2 2 3 2 3 1
9
2 2 1 3 1 1 1 3 3
9
2 3 3 1 3 3 3 1 2
9
1 2 2 1 1 1 1 3 3
9
2 1 1 2 3 2 3 2 3
9
2 1 3 2 1 2 1 1 2

output:

First
Second
Second
Second
Draw
Second
Draw
Second
Second
Second
Second
Second

result:

wrong answer 2nd lines differ - expected: 'First', found: 'Second'