QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#261563 | #4589. White-Black Tree | NYCU_gAwr_gurA# | RE | 0ms | 0kb | C++17 | 813b | 2023-11-22 23:42:01 | 2023-11-22 23:42:02 |
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define fast
#else
#define fast cin.tie(0)->sync_with_stdio(0)
#define endl '\n'
#define cerr if(1);else cerr
#endif
#define _ <<' '<<
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
vector<int> G[100010];
int arr[100010];
int dfs(int a, bool tag)
{
int res=0;
arr[a]^=tag;
res+=arr[a];
tag^=arr[a];
for(int b:G[a])
res+=dfs(b,tag);
}
signed main() {
fast;
int n;
cin>>n;
for(int i=2;i<=n;i++)
{
int a;
cin>>a;
G[a].emplace_back(i);
}
for(int i=1;i<=n;i++)
cin>>arr[i];
if(!dfs(1,0))
cout<<"First"<<endl;
else
cout<<"Second"<<endl;
cerr _ "meow" _ endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
7 1 1 1 3 3 3 0 1 1 0 0 0 1