Submission #1247623

#TimeUsernameProblemLanguageResultExecution timeMemory
124762312baaterBeech Tree (IOI23_beechtree)C++20
In queue
0 ms0 KiB
#include "beechtree.h" #include <vector> using namespace std; vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C) { bool all_same = 1; bool color = C[N-1]; vector<int> ans(N); for (int i = N-1; i >= 0; i++) { if (all_same == 0) { ans[i] = 0; } else { if (C[i] == color) { ans[i] = 1; } else { all_same = 0; ans[i] = 0; } } } return ans; }