QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68495#4797. XormitesA_zjzjWA 2ms3664kbC++141.1kb2022-12-16 21:11:202022-12-16 21:12:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-16 21:12:00]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3664kb
  • [2022-12-16 21:11:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using ll=long long;const int N=5e4+10;
int T,n,s,a[N],pre[N],suf[N];char buf[3][10]={"Draw","First","Second"};
int solve(int n,int *a){
	pre[1]=a[1];for(int j=3;j<=n;j+=2)pre[j]=pre[j-2]^a[j];
	suf[n]=a[n];for(int j=n-2;j>=1;j-=2)suf[j]=suf[j+2]^a[j];
	for(int j=1;j+2<=n;j+=2){
		int x=(j>1?pre[j-2]:0)^(j+4<=n?suf[j+4]:0);
		if(a[j]!=a[j+1]&&a[j+1]!=a[j+2])continue;
		if(a[j]==a[j+1]&&a[j+1]==a[j+2]){
			if(x)return 1;
		}
		else if(x^1)return 1;
	}
	return 2;
}
int get(){
	s=0;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]),s^=a[i];
	if(!s)return 0;if(!(n&1))return 1;for(int i=__lg(s);~i;i--)if(s>>i&1){
		if(n==1)return a[1]?1:2;
		if(n==2){
			if(a[1]==a[2])return a[1]?1:2;
			return 1;
		}
		for(int j=1;j<=n;j++)a[j]=a[j]>>i&1;
		for(int j=1;j+2<=n;j++)if(a[j]!=a[j+1]&&a[j+1]!=a[j+2])return 2;
//		return 1;
		int l=1,r=n,now=0;
		for(;l<=r&&a[l]==a[r];l++,r--)now^=a[l];
		if(l>r)return now&1?1:2;
		if(solve(r-l+1,a+l-1)==2)return 2;
		if(l>1&&solve(r-l+3,a+l-2)==2)return 2;
		return 1;
	}return 0;
}
int main(){
	for(scanf("%d",&T);T--;)puts(buf[get()]);return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3504kb

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: 3664kb

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: 0ms
memory: 3540kb

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: 3360kb

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: 3372kb

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: 3488kb

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: 3624kb

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: 3484kb

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: 0ms
memory: 3496kb

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: 3424kb

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: 2ms
memory: 3404kb

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: 1ms
memory: 3656kb

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: 3412kb

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:

Second
Second
Second
Second
Draw
Second
Draw
Second
Second
Second
Second
Second

result:

wrong answer 1st lines differ - expected: 'First', found: 'Second'