# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208530 | 2020-03-11T13:12:17 Z | dolphingarlic | popa (BOI18_popa) | C++14 | 0 ms | 0 KB |
#include "popa.h" int P[1000]; int solve(int N, int* L, int* R) { int root = -1; for (int i = 0; i < n; i++) { L[i] = R[i] = P[i] = -1; int par = i - 1; while (par != -1 && query(i, i, par, i)) { R[par] = L[i]; P[L[i]] = par; L[i] = par; int parpar = P[par]; P[par] = i; par = parpar; } if (par == -1) { L[i] = root; if (root != -1) P[root] = i; root = i; } else { R[par] = i; P[i] = par; } } return root; }