Submission #1083490

#TimeUsernameProblemLanguageResultExecution timeMemory
1083490SamueleVidBeech Tree (IOI23_beechtree)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; constexpr int MAXN = 2e5 + 5; constexpr int MAXM = 2e5 + 5; int depth[MAXN]; vector<int> adj[MAXN]; vector<int> P; vector<int> C; set<int> colori_prof[3]; int numero[3]; void dfs(int u) { colori_prof[depth[u]].insert(C[u]); numero[depth[u]] ++; for (auto x : adj[u]) { if (x == P[u]) continue; depth[x] = depth[u] + 1; dfs(x); } } vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) { :: P = P; :: C = C; for (int i = 1; i < N; i ++) { adj[P[i]].push_back(i); adj[i].push_back(P[i]); } dfs(0); vector<int> res(N, 1); if (colori_prof[2].size() == 1 && colori_prof[1].size() == numero[1]) { res[0] = 1; } else { res[0] = 0; } return res; } int main() { int N, M; assert(2 == scanf("%d %d", &N, &M)); vector<int> P(N); for (int i = 0; i < N; ++i) assert(1 == scanf("%d", &P[i])); vector<int> C(N); for (int i = 0; i < N; ++i) assert(1 == scanf("%d", &C[i])); fclose(stdin); vector<int> res = beechtree(N, M, P, C); int n = res.size(); for (int i = 0; i < n; ++i) { if (i > 0) printf(" "); printf("%d", res[i]); } printf("\n"); fclose(stdout); return 0; }

Compilation message (stderr)

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:38:61: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |     if (colori_prof[2].size() == 1 && colori_prof[1].size() == numero[1]) {
      |                                       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/cc1Zyj3A.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc6hDgoE.o:beechtree.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status