Submission #1038856

#TimeUsernameProblemLanguageResultExecution timeMemory
1038856fv3Beech Tree (IOI23_beechtree)C++17
0 / 100
69 ms17604 KiB
#include <bits/stdc++.h> #include "beechtree.h" using namespace std; vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) { vector<int> b(N); vector<vector<int>> adj(N); for (int i = 1; i < N; i++) { adj[P[i]].push_back(i); } map<int, int> colourCnt; for (auto node : adj[0]) { b[node] = 1; set<int> childColours; for (auto e : adj[node]) { if (childColours.count(C[e])) b[node] = 0; childColours.insert(C[e]); colourCnt[C[e]]++; b[e] = 1; } } b[0] = 1; set<int> childColours; for (auto node : adj[0]) { if (!b[node] || childColours.count(C[node])) { b[0] = 0; break; } childColours.insert(C[node]); } vector<int> cnts; for (auto n : colourCnt) { if (childColours.count(n.first) == 0) { b[0] = 0; break; } cnts.push_back(n.second); } sort(cnts.begin(), cnts.end()); for (int i = 0; i < cnts.size(); i++) { if (cnts[i] != i+1) { b[0] = 0; break; } } return b; }

Compilation message (stderr)

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < cnts.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...