Submission #1083492

#TimeUsernameProblemLanguageResultExecution timeMemory
1083492SamueleVidBeech Tree (IOI23_beechtree)C++17
0 / 100
2067 ms9852 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); bool same_as_parent = false; for (int i = 1; i < N; i ++) { if (P[i] == 0) continue; if (C[i] == C[P[i]]) same_as_parent = true; } if (colori_prof[2].size() == 1 && colori_prof[1].size() == numero[1] && same_as_parent) { res[0] = 1; } else { res[0] = 0; } return res; }

Compilation message (stderr)

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:44:61: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     if (colori_prof[2].size() == 1 && colori_prof[1].size() == numero[1] && same_as_parent) {
      |                                       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...