# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1038856 | fv3 | Beech Tree (IOI23_beechtree) | C++17 | 69 ms | 17604 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>
#include "beechtree.h"
using namespace std;
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C)
{
vector<int> b(N);
vector<vector<int>> adj(N);
for (int i = 1; i < N; i++)
{
adj[P[i]].push_back(i);
}
map<int, int> colourCnt;
for (auto node : adj[0])
{
b[node] = 1;
set<int> childColours;
for (auto e : adj[node])
{
if (childColours.count(C[e]))
b[node] = 0;
childColours.insert(C[e]);
colourCnt[C[e]]++;
b[e] = 1;
}
}
b[0] = 1;
set<int> childColours;
for (auto node : adj[0])
{
if (!b[node] || childColours.count(C[node]))
{
b[0] = 0;
break;
}
childColours.insert(C[node]);
}
vector<int> cnts;
for (auto n : colourCnt)
{
if (childColours.count(n.first) == 0)
{
b[0] = 0;
break;
}
cnts.push_back(n.second);
}
sort(cnts.begin(), cnts.end());
for (int i = 0; i < cnts.size(); i++)
{
if (cnts[i] != i+1)
{
b[0] = 0;
break;
}
}
return b;
}
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... |