제출 #980995

#제출 시각아이디문제언어결과실행 시간메모리
980995vjudge1Beech Tree (IOI23_beechtree)C++17
18 / 100
2011 ms18500 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]; bool CD(int xd) { fo(i,1,m)a[i]=0; int zd=0; priority_queue<tuple<int, int, int>> q; q.emplace(v[xd].size(), 0, xd); while (!q.empty()) { auto x=get<2>(q.top()); q.pop(); if(x!=xd){ if(a[c[x]]!=b[p[x]])return 0; a[c[x]]++; } b[x]=zd++; for(auto u:v[x])q.emplace(v[u].size(), -b[x], u); } return 1; } vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) { n=N; m=M; p=P; c=C;ans.resize(n); fo(i,1,n-1)v[p[i]].push_back(i); fo(i,0,n-1)ans[i]=CD(i); return ans; }
#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...