Submission #1088006

#TimeUsernameProblemLanguageResultExecution timeMemory
1088006Valaki2Beech Tree (IOI23_beechtree)C++17
5 / 100
61 ms20132 KiB
#include "beechtree.h" #include <bits/stdc++.h> using namespace std; #define pb push_back const int maxn = 2e5; int n, k; vector<int> g[maxn]; int par[maxn]; int col[maxn]; int ans[maxn]; void solve() { for(int i = n - 2; i >= 0; i--) { if(i != 0) if(col[i] != col[i + 1]) { ans[i - 1] = 0; } if(ans[i + 1] == 0) { ans[i] = 0; } } } vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) { n = N, k = M; for(int i = 0; i < n; i++) { par[i] = P[i]; col[i] = C[i]; if(i > 0) { g[par[i]].pb(i); } ans[i] = 1; } solve(); vector<int> answer(n); for(int i = 0; i < n; i++) { answer[i] = ans[i]; } return answer; }
#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...