QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212098 | #4589. White-Black Tree | ucup-team1004# | WA | 1ms | 6692kb | C++14 | 1.0kb | 2023-10-13 08:59:58 | 2023-10-13 08:59:59 |
Judging History
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'