Submission #843310

#TimeUsernameProblemLanguageResultExecution timeMemory
843310SHZhangBeech Tree (IOI23_beechtree)C++17
0 / 100
2 ms4952 KiB
#include "beechtree.h" #include <vector> #include <utility> using namespace std; int n, m; vector<int> p, c; vector<pair<int, int>> children[200005]; bool chain[200005]; int purecolor[200005]; int perms[15]; bool check(int i) { if (chain[i]) { return purecolor[i] != -1; } else { return false; } } void dfs(int node) { chain[node] = (children[node].size() <= 1); for (int i = 0; i < children[node].size(); i++) { int nxt = children[node][i].first; if (!chain[nxt]) { chain[node] = false; } else if (chain[node]) { if (children[nxt].size() == 0 || purecolor[nxt] == children[node][i].second) { purecolor[node] = children[node][i].second; } else { purecolor[node] = -1; } } } } std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C) { n = N; m = M; p = P; c = C; vector<int> ans; for (int i = 1; i < N; i++) { children[P[i]].push_back(make_pair(i, C[i])); } for (int i = 0; i < N; i++) { if (check(i)) ans.push_back(1); else ans.push_back(0); } return ans; }

Compilation message (stderr)

beechtree.cpp: In function 'void dfs(int)':
beechtree.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i = 0; i < children[node].size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~~
#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...