# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1066705 | LittleOrange | Beech Tree (IOI23_beechtree) | C++17 | 1 ms | 348 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;
using ll = int;
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
ll n = N;
ll m = M;
vector<vector<ll>> ch(n);
for(ll i = 1;i<n;i++) ch[P[i]].push_back(i);
vector<ll> ord;
{
function<void(ll)> dfs;
dfs = [&](ll i){
ord.push_back(i);
for(ll j : ch[i]) dfs(j);
};
dfs(0);
}
vector<ll> rord = ord;
reverse(rord.begin(),rord.end());
vector<ll> bad(n,0);
for(ll i : rord){
vector<ll> v;
for(ll j : ch[i]){
if (bad[j]) bad[i] = 1;
v.push_back(C[j]);
if(ch[i].size()<ch[j].size()) bad[i] = 1;
}
sort(v.begin(),v.end());
if (unique(v.begin(),v.end())!=v.end()) bad[i] = 1;
}
vector<ll> ans(n);
for(ll i = 0;i<n;i++) ans[i] = !bad[i];
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... |