QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#32209#2569. Kill All TermitesRobeZH#WA 5ms6104kbC++496b2022-05-18 01:38:592022-05-18 01:39:38

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-18 01:39:38]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:6104kb
  • [2022-05-18 01:38:59]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;

typedef vector<int> vi;

const int N = (int)1e5 + 50;

int n;
vi G[N];
int deg[N];


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    rep(i, 1, n) {
        int p;
        cin >> p; p--;
        deg[p]++;
        deg[i]++;
    }
    int res = 0;
    rep(i, 0, n) res += deg[i] > 2;
    res = max(res, 1);
    cout << res << '\n';

}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 5952kb

input:

1


output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2
1

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

8
1 1 2 1 2 3 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

3
1 1

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

4
1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

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

input:

5
1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

6
1 2 2 2 1

output:

1

result:

ok 1 number(s): "1"

Test #8:

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

input:

7
1 2 1 4 3 4

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

9
1 1 2 3 1 4 2 7

output:

2

result:

ok 1 number(s): "2"

Test #10:

score: 0
Accepted
time: 5ms
memory: 5956kb

input:

10
1 2 3 3 1 2 3 7 9

output:

2

result:

ok 1 number(s): "2"

Test #11:

score: -100
Wrong Answer
time: 0ms
memory: 5924kb

input:

11
1 1 2 1 5 6 7 3 3 2

output:

3

result:

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