This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int maxn = 2e5;
int n, k;
vector<int> g[maxn];
int par[maxn];
int col[maxn];
int ans[maxn];
void solve() {
for(int i = n - 2; i >= 0; i--) {
if(i != 0) if(col[i] != col[i + 1]) {
ans[i - 1] = 0;
}
if(ans[i + 1] == 0) {
ans[i] = 0;
}
}
}
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C)
{
n = N, k = M;
for(int i = 0; i < n; i++) {
par[i] = P[i];
col[i] = C[i];
if(i > 0) {
g[par[i]].pb(i);
}
ans[i] = 1;
}
solve();
vector<int> answer(n);
for(int i = 0; i < n; i++) {
answer[i] = ans[i];
}
return answer;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |