#include "beechtree.h"
#include <vector>
#include <utility>
using namespace std;
int n, m;
vector<int> p, c;
vector<pair<int, int>> children[200005];
bool chain[200005];
int purecolor[200005];
int perms[15];
bool check(int i)
{
if (chain[i]) {
return purecolor[i] != -1;
} else {
return false;
}
}
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
n = N; m = M; p = P; c = C;
vector<int> ans;
bool ischain = true;
for (int i = 1; i < N; i++) {
if (P[i] != i-1) ischain = false;
children[P[i]].push_back(make_pair(i, C[i]));
}
if (ischain) {
int last = N - 1;
while (last >= 1 && C[last] == C[N-1]) last--;
vector<int> ans;
for (int i = 0; i < last; i++) ans.push_back(0);
for (int i = 0; i < n - last; i++) ans.push_back(1);
return ans;
}
for (int i = 0; i < N; i++) {
if (check(i)) ans.push_back(1);
else ans.push_back(0);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4952 KB |
Output is correct |
3 |
Correct |
1 ms |
4952 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4952 KB |
Output is correct |
7 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4952 KB |
Output is correct |
3 |
Correct |
1 ms |
4952 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4952 KB |
Output is correct |
7 |
Correct |
58 ms |
19912 KB |
Output is correct |
8 |
Correct |
58 ms |
19656 KB |
Output is correct |
9 |
Correct |
2 ms |
4952 KB |
Output is correct |
10 |
Correct |
2 ms |
4952 KB |
Output is correct |
11 |
Correct |
1 ms |
4952 KB |
Output is correct |
12 |
Correct |
1 ms |
4956 KB |
Output is correct |
13 |
Correct |
2 ms |
5208 KB |
Output is correct |
14 |
Correct |
2 ms |
5208 KB |
Output is correct |
15 |
Correct |
2 ms |
5364 KB |
Output is correct |
16 |
Correct |
2 ms |
5212 KB |
Output is correct |
17 |
Correct |
54 ms |
19448 KB |
Output is correct |
18 |
Correct |
55 ms |
19600 KB |
Output is correct |
19 |
Correct |
54 ms |
19636 KB |
Output is correct |
20 |
Correct |
55 ms |
19668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4952 KB |
Output is correct |
3 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4952 KB |
Output is correct |
3 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4952 KB |
Output is correct |
3 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |