Submission #1039042

#TimeUsernameProblemLanguageResultExecution timeMemory
1039042ZicrusBeech Tree (IOI23_beechtree)C++17
9 / 100
86 ms20960 KiB
#include <bits/stdc++.h> #include "beechtree.h" using namespace std; typedef long long ll; vector<int> beechtree(int n, int m, vector<int> p, vector<int> c) { vector<int> res(n, 1); vector<vector<ll>> adj(n); for (int i = 1; i < n; i++) { adj[p[i]].push_back(i); } vector<pair<ll, ll>> szId(n); for (int i = 0; i < n; i++) { szId[i] = {adj[i].size(), i}; } sort(szId.begin(), szId.end()); unordered_set<ll> used; if (adj[0].size() != szId.back().first) res[0] = 0; for (auto &e : adj[0]) { if (used.count(c[e])) res[0] = 0; used.insert(c[e]); } for (int i = n-1; i >= 1; i--) { unordered_set<ll> nw; for (auto &e : adj[szId[i].second]) { if (!used.count(c[e])) res[0] = 0; if (nw.count(c[e])) res[szId[i].second] = res[0] = 0; nw.insert(c[e]); } used = nw; } return res; }

Compilation message (stderr)

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:19:23: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   19 |     if (adj[0].size() != szId.back().first) res[0] = 0;
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
#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...