QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#114435#4589. White-Black Treeberarchegas#WA 2ms6228kbC++201.0kb2023-06-22 02:25:452023-06-22 02:25:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-22 02:25:45]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6228kb
  • [2023-06-22 02:25:45]
  • 提交

answer

#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
 
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
    
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const ll INF = 2e18;

int fl, qt;

vector <int> grafo[MAXN];
int marc[MAXN];

void dfs(int v) {
    if(marc[v] == 1) {
        qt++;
        if(grafo[v].size() == 0) fl++;
        return;
    }
    for(int viz : grafo[v]) {
        dfs(viz);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 2; i <= n; i++) {
        int v;
        cin >> v;
        grafo[v].push_back(i);
    }
    for(int i = 1; i <= n; i++) cin >> marc[i];
    dfs(1);
    qt -= fl;
    if(qt == 0) {
        if(fl % 2 == 0) cout << "Second\n";
        else cout << "First\n";
    }
    else {
        if(qt % 2 == 0) cout << "Second\n";
        else cout << "First\n";
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5792kb

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

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

input:

4
1 1 1
1 1 0 1

output:

First

result:

ok single line: 'First'

Test #4:

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

input:

2
1
0 0

output:

Second

result:

ok single line: 'Second'

Test #5:

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

input:

3
1 2
0 1 1

output:

First

result:

ok single line: 'First'

Test #6:

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

input:

3
1 2
1 1 1

output:

First

result:

ok single line: 'First'

Test #7:

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

input:

3
1 1
1 1 1

output:

First

result:

ok single line: 'First'

Test #8:

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

input:

3
1 1
0 1 0

output:

First

result:

ok single line: 'First'

Test #9:

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

input:

3
1 1
0 1 1

output:

Second

result:

ok single line: 'Second'

Test #10:

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

input:

4
1 1 2
0 1 1 0

output:

First

result:

ok single line: 'First'

Test #11:

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

input:

4
1 1 1
0 1 1 1

output:

First

result:

ok single line: 'First'

Test #12:

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

input:

4
1 2 3
0 1 0 1

output:

First

result:

ok single line: 'First'

Test #13:

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

input:

5
1 1 2 2
0 1 1 1 1

output:

First

result:

ok single line: 'First'

Test #14:

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

input:

5
1 1 2 2
0 0 1 0 1

output:

Second

result:

ok single line: 'Second'

Test #15:

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

input:

2
1
1 0

output:

First

result:

ok single line: 'First'

Test #16:

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

input:

5
1 1 2 2
0 1 1 0 0

output:

First

result:

ok single line: 'First'

Test #17:

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

input:

5
1 1 1 2
0 1 1 1 1

output:

First

result:

ok single line: 'First'

Test #18:

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

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

input:

5
1 1 2 3
0 1 1 1 1

output:

Second

result:

ok single line: 'Second'

Test #20:

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

input:

5
1 1 2 3
0 1 1 1 0

output:

Second

result:

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