QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#67706#4589. White-Black Treekaruna#WA 4ms5896kbC++17599b2022-12-11 06:28:052022-12-11 06:28:06

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-11 06:28:06]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:5896kb
  • [2022-12-11 06:28:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 101010;
int n, col[N], dep[N], cnt[N];
vector<int> g[N];

void dfs(int v) {
    for (int x : g[v]) {
        dep[x] = dep[v] + 1;
        dfs(x);
    }
    if (col[v]) cnt[dep[v]] ^= 1;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int x; cin >> x;
        g[x].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> col[i];
    }
    dfs(1);
    int r = *max_element(cnt, cnt + N);
    cout << (r ? "First" : "Second");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5664kb

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: 2ms
memory: 5728kb

input:

5
1 1 2 3
0 1 1 0 0

output:

Second

result:

ok single line: 'Second'

Test #3:

score: 0
Accepted
time: 2ms
memory: 5668kb

input:

4
1 1 1
1 1 0 1

output:

First

result:

ok single line: 'First'

Test #4:

score: 0
Accepted
time: 3ms
memory: 5816kb

input:

2
1
0 0

output:

Second

result:

ok single line: 'Second'

Test #5:

score: 0
Accepted
time: 4ms
memory: 5720kb

input:

3
1 2
0 1 1

output:

First

result:

ok single line: 'First'

Test #6:

score: 0
Accepted
time: 4ms
memory: 5732kb

input:

3
1 2
1 1 1

output:

First

result:

ok single line: 'First'

Test #7:

score: 0
Accepted
time: 2ms
memory: 5800kb

input:

3
1 1
1 1 1

output:

First

result:

ok single line: 'First'

Test #8:

score: 0
Accepted
time: 1ms
memory: 5896kb

input:

3
1 1
0 1 0

output:

First

result:

ok single line: 'First'

Test #9:

score: 0
Accepted
time: 4ms
memory: 5812kb

input:

3
1 1
0 1 1

output:

Second

result:

ok single line: 'Second'

Test #10:

score: -100
Wrong Answer
time: 4ms
memory: 5796kb

input:

4
1 1 2
0 1 1 0

output:

Second

result:

wrong answer 1st lines differ - expected: 'First', found: 'Second'