QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#67704#4589. White-Black Treekaruna#WA 25ms8264kbC++17919b2022-12-11 06:14:042022-12-11 06:14: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:14:06]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:8264kb
  • [2022-12-11 06:14:04]
  • 提交

answer

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

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

void dfs(int v) {
    priority_queue<int> q;
    for (int x : g[v]) {
        dfs(x);
        q.push(dp[x]);
    }
    for (int i = 30; i >= 0; i--) {
        if (!q.empty() && q.top() >> i & 1) {
            int x = q.top(); q.pop();
            q.push(x - (1 << i));
            dp[v] |= (1 << i);
        }
    }
    ++dp[v];
}
int solve(int v) {
    int res = 0;
    for (int x : g[v]) {
        res ^= solve(x);
    }
    return col[v] ? dp[v] + res : res;
}
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 = solve(1);
    cout << (r ? "First" : "Second");
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 5684kb

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: 0ms
memory: 6524kb

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: 5660kb

input:

4
1 1 1
1 1 0 1

output:

First

result:

ok single line: 'First'

Test #4:

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

input:

2
1
0 0

output:

Second

result:

ok single line: 'Second'

Test #5:

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

input:

3
1 2
0 1 1

output:

First

result:

ok single line: 'First'

Test #6:

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

input:

3
1 2
1 1 1

output:

First

result:

ok single line: 'First'

Test #7:

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

input:

3
1 1
1 1 1

output:

First

result:

ok single line: 'First'

Test #8:

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

input:

3
1 1
0 1 0

output:

First

result:

ok single line: 'First'

Test #9:

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

input:

3
1 1
0 1 1

output:

Second

result:

ok single line: 'Second'

Test #10:

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

input:

4
1 1 2
0 1 1 0

output:

First

result:

ok single line: 'First'

Test #11:

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

input:

4
1 1 1
0 1 1 1

output:

First

result:

ok single line: 'First'

Test #12:

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

input:

4
1 2 3
0 1 0 1

output:

First

result:

ok single line: 'First'

Test #13:

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

input:

5
1 1 2 2
0 1 1 1 1

output:

First

result:

ok single line: 'First'

Test #14:

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

input:

5
1 1 2 2
0 0 1 0 1

output:

Second

result:

ok single line: 'Second'

Test #15:

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

input:

2
1
1 0

output:

First

result:

ok single line: 'First'

Test #16:

score: 0
Accepted
time: 0ms
memory: 5660kb

input:

5
1 1 2 2
0 1 1 0 0

output:

First

result:

ok single line: 'First'

Test #17:

score: 0
Accepted
time: 0ms
memory: 5748kb

input:

5
1 1 1 2
0 1 1 1 1

output:

First

result:

ok single line: 'First'

Test #18:

score: 0
Accepted
time: 0ms
memory: 5804kb

input:

5
1 1 1 2
0 1 1 1 1

output:

First

result:

ok single line: 'First'

Test #19:

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

input:

5
1 1 2 3
0 1 1 1 1

output:

Second

result:

ok single line: 'Second'

Test #20:

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

input:

5
1 1 2 3
0 1 1 1 0

output:

First

result:

ok single line: 'First'

Test #21:

score: 0
Accepted
time: 0ms
memory: 5724kb

input:

6
1 1 1 3 3
0 1 0 1 1 1

output:

Second

result:

ok single line: 'Second'

Test #22:

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

input:

6
1 1 1 3 3
0 1 1 0 1 1

output:

First

result:

ok single line: 'First'

Test #23:

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

input:

8
1 2 3 4 5 6 7
0 1 1 1 1 1 1 1

output:

First

result:

ok single line: 'First'

Test #24:

score: 0
Accepted
time: 0ms
memory: 5860kb

input:

10
1 1 1 2 3 4 5 6 7
0 1 1 1 1 1 1 1 1 1

output:

First

result:

ok single line: 'First'

Test #25:

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

input:

15
1 1 2 2 3 3 4 4 5 5 6 6 7 7
0 1 0 0 1 0 0 0 0 0 0 0 0 0 1

output:

First

result:

ok single line: 'First'

Test #26:

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

input:

2
1
0 1

output:

First

result:

ok single line: 'First'

Test #27:

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

input:

13
1 1 1 2 3 4 5 6 7 8 9 10
0 1 1 1 1 1 1 1 1 1 1 1 1

output:

First

result:

ok single line: 'First'

Test #28:

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

input:

32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

First

result:

ok single line: 'First'

Test #29:

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

input:

33
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

First

result:

ok single line: 'First'

Test #30:

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

input:

34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

First

result:

ok single line: 'First'

Test #31:

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

input:

256
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

output:

First

result:

ok single line: 'First'

Test #32:

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

input:

257
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

output:

First

result:

ok single line: 'First'

Test #33:

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

input:

258
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

output:

First

result:

ok single line: 'First'

Test #34:

score: 0
Accepted
time: 25ms
memory: 8264kb

input:

100000
1 2 3 4 4 6 4 7 4 7 8 5 6 5 14 1 17 5 8 10 17 18 13 12 15 11 25 24 3 11 3 21 1 13 30 35 29 6 34 35 41 20 35 36 21 24 37 33 6 37 33 31 8 30 52 43 30 7 25 29 17 12 49 48 30 15 39 10 2 23 44 11 45 17 47 30 73 71 54 36 30 51 37 76 60 9 6 86 60 59 62 16 20 34 13 73 31 60 37 33 58 4 46 66 104 102 1...

output:

First

result:

ok single line: 'First'

Test #35:

score: -100
Wrong Answer
time: 18ms
memory: 8160kb

input:

99999
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 ...

output:

First

result:

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