Submission #1074721

#TimeUsernameProblemLanguageResultExecution timeMemory
1074721UnforgettableplBeech Tree (IOI23_beechtree)C++17
26 / 100
2043 ms19384 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> ans(N); vector<vector<int>> adj(N); for(int i=1;i<N;i++)adj[P[i]].emplace_back(i); auto check = [&](int root){ map<int,int> cnt; priority_queue<tuple<int,int,int>> q; vector<int> seq = {root}; for(int&i:adj[root])q.emplace(adj[i].size(),0,i); while(!q.empty()) { auto [a,b,curr] = q.top();q.pop(); if(seq[cnt[C[curr]]]!=P[curr])return false; cnt[C[curr]]++; seq.emplace_back(curr); for(int&i:adj[curr])q.emplace(adj[i].size(),-(seq.size()-1),i); } return true; }; for(int i=0;i<N;i++)if(check(i))ans[i]=1; 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...