# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
848269 | Plurm | Beech Tree (IOI23_beechtree) | C++17 | 1 ms | 600 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 <bits/stdc++.h>
using namespace std;
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) {
vector<int> dep(N);
dep[0] = 0;
vector<set<int>> chs(N);
vector<int> d1c;
d1c.resize(M + 1, 0);
vector<int> d2c;
d2c.resize(M + 1, 0);
vector<int> ret;
ret.resize(N, 1);
bool flag = true;
for (int i = 1; i < N; i++) {
if (P[i] == 0)
dep[i] = 1;
else
dep[i] = 2;
if (chs[P[i]].count(C[i])) {
ret[P[i]] = 0;
flag = false;
}
chs[P[i]].insert(C[i]);
if (dep[i] == 2) {
d2c[C[i]]++;
} else {
d1c[C[i]]++;
}
}
if (!flag)
ret[0] = 0;
vector<int> vs;
for (int i = 1; i <= M; i++) {
if (d2c[i] != 0 && d1c[i] == 0)
ret[0] = 0;
if (d1c[i] != 0)
vs.push_back(d2c[i]);
}
sort(vs.begin(), vs.end());
for (int i = 0; i < vs.size(); i++) {
if (vs[i] <= i)
ret[0] = 0;
}
return ret;
}
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... |