# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1221336 | im2xtreme | 참나무 (IOI23_beechtree) | C++20 | 0 ms | 0 KiB |
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include "beechtree.h"
using namespace std;
const int MAXN = 200005;
vector<int> tree[MAXN];
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) {
vector<int> result(N, 1); // Assume beautiful until proven otherwise
// Build the tree
for (int i = 0; i < N; ++i) tree[i].clear();
for (int i = 1; i < N; ++i) {
tree[P[i]].push_back(i);
}
// Process each node as subtree root
for (int root = 0; root < N; ++root) {
vector<int> perm; // Beautiful permutation we’re trying to construct
unordered_map<int, int> color_cnt; // Frequency of colo