# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061897 | mychecksedad | Beech Tree (IOI23_beechtree) | C++17 | 2098 ms | 11348 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;
#define pb push_back
#define all(x) x.begin(),x.end()
#define ll long long
#define ff first
#define ss second
#define vi vector<int>
const int N = 3005;
const ll INF = 1e18;
vector<int> g[N], s[N];
vi res;
int col[N], n, m, par[N];
bool ok = 1;
void dfs(int v){
for(int u: g[v]){
dfs(u);
par[u] = v;
for(int x: s[u]) s[v].pb(x);
}
sort(all(s[v]));
bool okkk = 0;
if(s[v].empty()) okkk = 1;
do{
vector<int> f = s[v];
f.insert(f.begin(), v);
vector<int> co(m);
bool good = 1;
for(int i = 1; i < f.size(); ++i){
if(f[co[col[f[i]]]] != par[f[i]]){
good = 0;
break;
}
co[col[f[i]]]++;
}
if(good){
okkk = 1;
break;
}
}while(next_permutation(all(s[v])));
s[v].pb(v);
// ok = ok & okkk;
res[v] = okkk;
}
std::vector<int> beechtree(int nn, int mm, std::vector<int> P, std::vector<int> C)
{n=nn, m=mm;
res.resize(n);
for(int i = 1; i < n; ++i){
g[P[i]].pb(i);
col[i] = C[i];
}
dfs(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... |