# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
843310 | SHZhang | Beech Tree (IOI23_beechtree) | C++17 | 2 ms | 4952 KiB |
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 <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;
}
}
void dfs(int node)
{
chain[node] = (children[node].size() <= 1);
for (int i = 0; i < children[node].size(); i++) {
int nxt = children[node][i].first;
if (!chain[nxt]) {
chain[node] = false;
} else if (chain[node]) {
if (children[nxt].size() == 0 || purecolor[nxt] == children[node][i].second) {
purecolor[node] = children[node][i].second;
} else {
purecolor[node] = -1;
}
}
}
}
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;
for (int i = 1; i < N; i++) {
children[P[i]].push_back(make_pair(i, C[i]));
}
for (int i = 0; i < N; i++) {
if (check(i)) ans.push_back(1);
else ans.push_back(0);
}
return ans;
}
Compilation message (stderr)
# | 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... |