Submission #981030

#TimeUsernameProblemLanguageResultExecution timeMemory
981030vjudge1Beech Tree (IOI23_beechtree)C++17
58 / 100
2039 ms54760 KiB
// hola soy Dember :D // 31/03/2024 #include <bits/stdc++.h> #include "beechtree.h" #define ll long long #define pll pair<ll,ll> #define F first #define S second #define Z size() #define pb push_back #define bp pop_back #define fo(x,y,z) for(ll x=y; x<=z; x++) #define of(x,y,z) for(ll x=y; x>=z; x--) #define all(n) n.begin(), n.end() #define arr(x,y,z) x+y, x+y+z using namespace std; const int MN=2e5+5; int n, m; vector<int> v[MN], p, c, ans; int a[MN], b[MN]; void CD(int xd=0){ b[xd]=1; for (int &u: v[xd]){ CD(u); b[xd]+=b[u]; } priority_queue<tuple<int, int, int>> q; q.emplace(b[xd], 0, xd); vector<int> V; fo(i,0,m+1)a[i]=0; while(!q.empty()){ auto x=get<2>(q.top()); q.pop(); if (x!=xd) { if(a[c[x]]>=V.size() || V[a[c[x]]]!=p[x])return; a[c[x]]++; } V.push_back(x); for(int u:v[x])q.emplace(b[u], -V.size(), u); } ans[xd]=1; return; } vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) { n=N; m=M; p=P; c=C;ans.resize(n,0); fo(i,1,n-1)v[p[i]].pb(i); CD(); return ans; }

Compilation message (stderr)

beechtree.cpp: In function 'void CD(int)':
beechtree.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             if(a[c[x]]>=V.size() || V[a[c[x]]]!=p[x])return;
      |                ~~~~~~~^~~~~~~~~~
#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...