QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#32209 | #2569. Kill All Termites | RobeZH# | WA | 5ms | 6104kb | C++ | 496b | 2022-05-18 01:38:59 | 2022-05-18 01:39:38 |
Judging History
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';
}
Details
Tip: Click on the bar to expand more detailed information
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'