# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078114 | MohamedFaresNebili | Beech Tree (IOI23_beechtree) | C++17 | 2092 ms | 4956 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> adj[200005];
void getSub(int v, vector<int>& sub) {
sub.push_back(v);
for(auto u : adj[v])
getSub(u, sub);
}
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) {
vector<int> ans(N, 0);
for(int l = 0; l < N; l++) adj[l].clear();
for(int l = 1; l < N; l++)
adj[P[l]].push_back(l);
for(int l = 0; l < N; l++) {
vector<int> sub; getSub(l, sub);
sort(sub.begin() + 1, sub.end());
do {
bool ok = true;
vector<int> cur(M, 0);
for(int i = 0; i < sub.size() && ok; i++) {
if(i > 0) ok &= (P[sub[i]] == sub[cur[C[sub[i]]]]);
cur[C[sub[i]]]++;
}
if(ok) { ans[l] = 1; break; }
} while(!next_permutation(sub.begin() + 1, sub.end()));
}
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... |