# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083495 | SamueleVid | Beech Tree (IOI23_beechtree) | C++17 | 2076 ms | 10072 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 <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 2e5 + 5;
constexpr int MAXM = 2e5 + 5;
int depth[MAXN];
vector<int> adj[MAXN];
vector<int> P;
vector<int> C;
set<int> colori_prof[3];
int numero[3];
void dfs(int u) {
colori_prof[depth[u]].insert(C[u]);
numero[depth[u]] ++;
for (auto x : adj[u]) {
if (x == P[u]) continue;
depth[x] = depth[u] + 1;
dfs(x);
}
}
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) {
:: P = P;
:: C = C;
for (int i = 1; i < N; i ++) {
adj[P[i]].push_back(i);
adj[i].push_back(P[i]);
}
depth[0] = 0;
dfs(0);
vector<int> res(N, 1);
bool condivide_uno = 0;
for (auto x : colori_prof[2]) {
if (colori_prof[1].count(x)) condivide_uno = 1;
}
if (colori_prof[2].size() == 1 && colori_prof[1].size() == numero[1] && condivide_uno) {
res[0] = 1;
}
else {
res[0] = 0;
}
return res;
}
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... |