#include <bits/stdc++.h>
using namespace std;
int const N=2e5+5;
vector<int> child[N];
set<int> ch_col[N];
vector<int> ans;
int dep[N];
void dfs(int node){
ans[node]=1;
vector<int> ch;
for(int i:child[node]){
dfs(i);
ans[node]&=ans[i];
dep[node]=max(dep[node]+1,dep[node]);
if(dep[i]==1)
ch.push_back(i);
}
if(ch.size()>1 || ans[node]==0 || dep[node]>=2 || child[node].size()!=ch_col[node].size()){
ans[node]=0;
return;
}
if(ch.size()==0)
return;
for(int c:ch_col[ch[0]])
if(ch_col[node].find(c)==ch_col[node].end())
ans[node]=0;
return;
}
vector<int> beechtree(int n, int M, vector<int> P, vector<int> C){
for (int i = 1; i < n; ++i){
child[P[i]].push_back(i);
ch_col[P[i]].insert(C[i]);
}
ans.resize(n);
dfs(0);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
14940 KB |
Output is correct |
2 |
Incorrect |
3 ms |
14936 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
2 ms |
14940 KB |
Output is correct |
3 |
Correct |
2 ms |
15128 KB |
Output is correct |
4 |
Correct |
2 ms |
14936 KB |
Output is correct |
5 |
Correct |
2 ms |
14940 KB |
Output is correct |
6 |
Correct |
2 ms |
14936 KB |
Output is correct |
7 |
Correct |
2 ms |
15140 KB |
Output is correct |
8 |
Incorrect |
2 ms |
14940 KB |
2nd lines differ - on the 1st token, expected: '1', found: '0' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
2 ms |
14940 KB |
Output is correct |
3 |
Correct |
2 ms |
15128 KB |
Output is correct |
4 |
Correct |
2 ms |
14936 KB |
Output is correct |
5 |
Correct |
2 ms |
14940 KB |
Output is correct |
6 |
Correct |
2 ms |
14936 KB |
Output is correct |
7 |
Correct |
79 ms |
62988 KB |
Output is correct |
8 |
Correct |
76 ms |
62292 KB |
Output is correct |
9 |
Correct |
2 ms |
15144 KB |
Output is correct |
10 |
Correct |
3 ms |
14940 KB |
Output is correct |
11 |
Correct |
3 ms |
14936 KB |
Output is correct |
12 |
Correct |
2 ms |
14940 KB |
Output is correct |
13 |
Correct |
4 ms |
15452 KB |
Output is correct |
14 |
Correct |
4 ms |
15452 KB |
Output is correct |
15 |
Correct |
3 ms |
15368 KB |
Output is correct |
16 |
Correct |
3 ms |
15452 KB |
Output is correct |
17 |
Correct |
87 ms |
62292 KB |
Output is correct |
18 |
Correct |
89 ms |
62204 KB |
Output is correct |
19 |
Correct |
85 ms |
62308 KB |
Output is correct |
20 |
Correct |
76 ms |
62292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
14940 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
2 ms |
14940 KB |
Output is correct |
3 |
Correct |
2 ms |
15140 KB |
Output is correct |
4 |
Incorrect |
2 ms |
14940 KB |
2nd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
14940 KB |
Output is correct |
2 |
Incorrect |
3 ms |
14936 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
2 ms |
14940 KB |
Output is correct |
3 |
Correct |
2 ms |
15140 KB |
Output is correct |
4 |
Incorrect |
2 ms |
14940 KB |
2nd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
14940 KB |
Output is correct |
2 |
Incorrect |
3 ms |
14936 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
2 ms |
14940 KB |
Output is correct |
3 |
Correct |
2 ms |
15140 KB |
Output is correct |
4 |
Incorrect |
2 ms |
14940 KB |
2nd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
14940 KB |
Output is correct |
2 |
Incorrect |
3 ms |
14936 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |