Submission #1074756

#TimeUsernameProblemLanguageResultExecution timeMemory
1074756UnforgettableplBeech Tree (IOI23_beechtree)C++17
0 / 100
1 ms428 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); function<int(int)> dfs = [&](int x){ vector<bool> contains(3); int state = -1; for(int&i:adj[x]) { if(contains[C[i]])return -2; contains[C[i]]=true; auto curr = dfs(i); if(curr==-2)return -2; if(curr==-1)continue; if(state!=-1 and state!=curr)return -2; state=curr; } if(contains[1] and !contains[2]) { if(state==2)return -2; state=1; } if(!contains[1] and contains[2]) { if(state==1)return -2; state=2; } ans[x]=1; return state; }; dfs(0); 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...