QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212107 | #4589. White-Black Tree | ucup-team1004# | WA | 1ms | 7116kb | C++14 | 1.0kb | 2023-10-13 09:06:09 | 2023-10-13 09:06:09 |
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,d[N],f[N];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--){
for(int j:S[i]) d[i]=max(d[i],d[j]+1);
}
int ans=0;for(i=1;i<=n;i++) {int x;scanf("%d",&x);if(x) f[d[i]]^=1;}
for(i=1;i<=n;i++) if(f[i]){puts("First");return;}
puts("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: 6212kb
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: 1ms
memory: 6336kb
input:
5 1 1 2 3 0 1 1 0 0
output:
Second
result:
ok single line: 'Second'
Test #3:
score: 0
Accepted
time: 0ms
memory: 6228kb
input:
4 1 1 1 1 1 0 1
output:
First
result:
ok single line: 'First'
Test #4:
score: 0
Accepted
time: 1ms
memory: 6348kb
input:
2 1 0 0
output:
Second
result:
ok single line: 'Second'
Test #5:
score: 0
Accepted
time: 0ms
memory: 6556kb
input:
3 1 2 0 1 1
output:
First
result:
ok single line: 'First'
Test #6:
score: 0
Accepted
time: 0ms
memory: 6352kb
input:
3 1 2 1 1 1
output:
First
result:
ok single line: 'First'
Test #7:
score: 0
Accepted
time: 1ms
memory: 7016kb
input:
3 1 1 1 1 1
output:
First
result:
ok single line: 'First'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 7116kb
input:
3 1 1 0 1 0
output:
Second
result:
wrong answer 1st lines differ - expected: 'First', found: 'Second'