| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1363938 | avighna | Beech Tree (IOI23_beechtree) | C++20 | 2097 ms | 50344 KiB |
#include <bits/stdc++.h>
using namespace std;
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) {
vector<vector<int>> adj(N);
for (int i = 1; i < N; ++i) {
adj[P[i]].push_back(i);
}
vector<int> ans(N);
auto dfs = [&](auto &&self, int u) -> vector<int> {
vector<int> nodes;
for (auto &i : adj[u]) {
for (auto &node : self(self, i)) {
nodes.push_back(node);
}
}
nodes.push_back(u);
reverse(nodes.begin(), nodes.end());
if (nodes.size() == 1) {
ans[u] = 1;
} else {
sort(nodes.begin() + 1, nodes.end());
do {
int good = 1;
vector<int> cnt(M + 1);
for (int i = 1; i < int(nodes.size()); ++i) {
if (P[nodes[i]] != nodes[cnt[C[nodes[i]]]]) {
good = 0;
}
cnt[C[nodes[i]]]++;
}
ans[u] |= good;
} while (next_permutation(nodes.begin() + 1, nodes.end()));
}
return nodes;
};
dfs(dfs, 0);
return ans;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
