QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706803#4589. White-Black Treearnold518#WA 1ms6832kbC++17742b2024-11-03 13:31:362024-11-03 13:31:37

Judging History

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

  • [2024-11-03 13:31:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6832kb
  • [2024-11-03 13:31:36]
  • 提交

answer

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

typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N;
vector<int> adj[MAXN+10];
int h[MAXN+10], cnt[MAXN+10], A[MAXN+10];

void dfs(int now)
{
    for(int nxt : adj[now])
    {
        dfs(nxt);
        h[now]=max(h[nxt]+1, h[now]);
    }
    if(A[now]) cnt[h[now]]=1-cnt[h[now]];
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    cin >> N;
    for(int i=2; i<=N; i++)
    {
        int p;
        cin >> p;
        adj[p].push_back(i);
    }
    for(int i=1; i<=N; i++) cin >> A[i];

    dfs(1);
    for(int i=0; i<=N; i++) if(cnt[i]) return !(cout << "first\n");
    cout << "second\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6832kb

input:

7
1 1 1 3 3 3
0 1 1 0 0 0 1

output:

first

result:

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