QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#65374 | #4589. White-Black Tree | T3alaadl3k2olyehymn3k | WA | 2ms | 8052kb | C++20 | 763b | 2022-11-29 23:40:36 | 2022-11-29 23:40:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 69;
vector<int> G[N];
int h[N], col[N];
map<int, vector<int>> a;
void dfs(int root, int par) {
h[root] = h[par] + 1;
if (!col[root]) {
a[h[root]].push_back(col[root]);
}
for (auto i: G[root]) {
if (i == par)continue;
dfs(i, root);
}
}
signed main() {
int n;
cin >> n;
for (int i = 2; i <= n; i++) {
int u;
cin >> u;
G[u].push_back(i);
G[i].push_back(u);
}
for (int i = 1; i <= n; i++) {
cin >> col[i];
}
dfs(1, 0);
bool flag = 0;
for (auto i: a)
flag |= (i.second.size() % 2);
cout << (!flag ? "First" : "Second") << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 8052kb
input:
7 1 1 1 3 3 3 0 1 1 0 0 0 1
output:
Second
result:
wrong answer 1st lines differ - expected: 'First', found: 'Second'