QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#212098#4589. White-Black Treeucup-team1004#WA 1ms6692kbC++141.0kb2023-10-13 08:59:582023-10-13 08:59:59

Judging History

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

  • [2023-10-13 08:59:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6692kb
  • [2023-10-13 08:59:58]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e5+5,M=(1<<20)+5,K=600+5,mod=1e9+7,Mod=mod-1;const db eps=1e-6;const ll INF=1e18+7;mt19937 rnd(263082);
int n,sg[N],f[50];vector<int> S[N];
void Solve(){
	int i,j;scanf("%d",&n);
	for(i=2;i<=n;i++) {int x;scanf("%d",&x);S[x].emplace_back(i);}
	for(i=n;i;i--){
		Me(f,0);
		for(int j:S[i]) f[sg[j]]=1;
		while(f[sg[i]]) sg[i]++;//cerr<<sg[i]<<' ';
	}
	int ans=0;for(i=1;i<=n;i++) {int x;scanf("%d",&x);if(x) ans^=sg[i];}
	puts(ans?"First":"Second");
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6396kb

input:

7
1 1 1 3 3 3
0 1 1 0 0 0 1

output:

First

result:

ok single line: 'First'

Test #2:

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

input:

5
1 1 2 3
0 1 1 0 0

output:

Second

result:

ok single line: 'Second'

Test #3:

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

input:

4
1 1 1
1 1 0 1

output:

First

result:

ok single line: 'First'

Test #4:

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

input:

2
1
0 0

output:

Second

result:

ok single line: 'Second'

Test #5:

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

input:

3
1 2
0 1 1

output:

First

result:

ok single line: 'First'

Test #6:

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

input:

3
1 2
1 1 1

output:

First

result:

ok single line: 'First'

Test #7:

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

input:

3
1 1
1 1 1

output:

First

result:

ok single line: 'First'

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 6320kb

input:

3
1 1
0 1 0

output:

Second

result:

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