Submission #848269

#TimeUsernameProblemLanguageResultExecution timeMemory
848269PlurmBeech Tree (IOI23_beechtree)C++17
0 / 100
1 ms600 KiB
#include "beechtree.h" #include <bits/stdc++.h> using namespace std; vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) { vector<int> dep(N); dep[0] = 0; vector<set<int>> chs(N); vector<int> d1c; d1c.resize(M + 1, 0); vector<int> d2c; d2c.resize(M + 1, 0); vector<int> ret; ret.resize(N, 1); bool flag = true; for (int i = 1; i < N; i++) { if (P[i] == 0) dep[i] = 1; else dep[i] = 2; if (chs[P[i]].count(C[i])) { ret[P[i]] = 0; flag = false; } chs[P[i]].insert(C[i]); if (dep[i] == 2) { d2c[C[i]]++; } else { d1c[C[i]]++; } } if (!flag) ret[0] = 0; vector<int> vs; for (int i = 1; i <= M; i++) { if (d2c[i] != 0 && d1c[i] == 0) ret[0] = 0; if (d1c[i] != 0) vs.push_back(d2c[i]); } sort(vs.begin(), vs.end()); for (int i = 0; i < vs.size(); i++) { if (vs[i] <= i) ret[0] = 0; } return ret; }

Compilation message (stderr)

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