Submission #1221334

#TimeUsernameProblemLanguageResultExecution timeMemory
1221334im2xtremeBeech Tree (IOI23_beechtree)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <unordered_map> #include "beechtree.h" using namespace std; const int MAXN = 200005; vector<int> tree[MAXN]; int result[MAXN]; void collect_subtree(int u, vector<int>& nodes) { nodes.push_back(u); for (int v : tree[u]) { collect_subtree(v, nodes); } } bool is_beautiful(const vector<int>& P, const vector<int>& C, int root) { vector<int> nodes; collect_subtree(root, nodes); if (nodes[0] != root) return false; unordered_map<int, int> color_count; for (int i = 1; i < (int)nodes.size(); ++i) { int curr = nodes[i]; int color = C[curr]; int f = color_count[color]; if (f >= i || P[curr] != nodes[f]) return false; color_count[color]++; } return true; } int* beechtree(int N, int M, vector<int> P, vector<int> C) { for (int i = 0; i < N; ++i) { tree[i].clear(); } for (int i = 1; i < N; ++i) { tree[P[i]].push_back(i); } for (int i = 0; i < N; ++i) { result[i] = is_beautiful(P, C, i) ? 1 : 0; } return result; }

Compilation message (stderr)

beechtree.cpp:40:6: error: ambiguating new declaration of 'int* beechtree(int, int, std::vector<int>, std::vector<int>)'
   40 | int* beechtree(int N, int M, vector<int> P, vector<int> C) {
      |      ^~~~~~~~~
In file included from beechtree.cpp:4:
beechtree.h:3:18: note: old declaration 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)'
    3 | std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C);
      |                  ^~~~~~~~~