QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227529#2569. Kill All TermitesJooDdaeWA 0ms5964kbC++20466b2023-10-27 17:29:082023-10-27 17:29:08

Judging History

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

  • [2023-10-27 17:29:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5964kb
  • [2023-10-27 17:29:08]
  • 提交

answer

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

int n;
vector<int> v[100100];

int ans;

int dfs(int u) {
    if(v[u].empty()) return 1;

    int re = 0;
    for(auto x : v[u]) re += dfs(x);
    if(re > 1) ans++, re = 0;
    return re;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for(int i=2;i<=n;i++) {
        int p; cin >> p;
        v[p].push_back(i);
    }
    dfs(1);
    cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 5964kb

input:

1


output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'