QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#728124 | #4589. White-Black Tree | MeatInTheMiddle# | WA | 1ms | 6632kb | C++17 | 1.0kb | 2024-11-09 14:36:41 | 2024-11-09 14:36:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fastio (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL))
typedef long long ll;
typedef long double lld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const int MAXSIZE = 2000000;
const long long INF = 1e18 + 5;
const double EPSILON = 1e-14;
const ll DIV = 2000003;
const long double pi = 3.14159265358979323846264338327950288419716939937510L;
int n;
int tg[101001];
int cnt[101010];
vector<int> adj[101010];
int dfs(int cur)
{
int ret = 0;
cnt[cur] = 1;
for (int nxt : adj[cur])
{
ret ^= dfs(nxt);
cnt[cur] += cnt[nxt];
}
if (tg[cur])
ret ^= cnt[cur];
return ret;
}
int main()
{
fastio;
cin >> n;
for (int i = 2; i <= n; i++)
{
int a;
cin >> a;
adj[a].push_back(i);
}
for (int i = 1; i <= n; i++)
cin >> tg[i];
int t = dfs(1);
if (t)
cout << "First";
else
cout << "Second";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6060kb
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: 5952kb
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: 6080kb
input:
4 1 1 1 1 1 0 1
output:
First
result:
ok single line: 'First'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5960kb
input:
2 1 0 0
output:
Second
result:
ok single line: 'Second'
Test #5:
score: 0
Accepted
time: 1ms
memory: 6632kb
input:
3 1 2 0 1 1
output:
First
result:
ok single line: 'First'
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 6072kb
input:
3 1 2 1 1 1
output:
Second
result:
wrong answer 1st lines differ - expected: 'First', found: 'Second'