# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995442 | irmuun | Beech Tree (IOI23_beechtree) | C++17 | 2028 ms | 20444 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;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define pii pair<int,int>
vector<int>beechtree(int n,int m,vector<int>p,vector<int>c){
vector<int>g[n];
for(int i=1;i<n;i++){
g[p[i]].pb(i);
}
function <bool(int,int)> comp=[&](int i,int j){
return g[i].size()>g[j].size();
};
vector<int>b(n,0),f(m+1,0);
for(int i=0;i<n;i++){
vector<int>u;
priority_queue<pii,vector<pii>,greater<pii>>q;
q.push({g[i].size(),i});
while(!q.empty()){
auto [sz,x]=q.top();
u.pb(x);
q.pop();
for(int y:g[x]){
q.push({g[y].size(),y});
}
}
bool ok=true;
for(int j=1;j<u.size();j++){
if(p[u[j]]!=u[f[c[u[j]]]]){
ok=false;
break;
}
f[c[u[j]]]++;
}
if(ok){
b[i]=1;
}
fill(all(f),0);
}
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... |