Submission #59772

#TimeUsernameProblemLanguageResultExecution timeMemory
59772model_codepopa (BOI18_popa)C++17
61 / 100
192 ms664 KiB
#include <bits/stdc++.h> #include "popa.h" using namespace std; const int MaxN = 10010; int lf[MaxN], rg[MaxN]; int dfs(int l, int r) { if (l > r) return -1; int a = l, b = r; while (1) { if (query(l, r, a, a)) { lf[a] = dfs(l, a - 1); rg[a] = dfs(a + 1, r); return a; } if (query(l, r, b, b)) { lf[b] = dfs(l, b - 1); rg[b] = dfs(b + 1, r); return b; } a++; b--; } } int solve(int n, int* left, int* right) { int root = dfs(0, n - 1); for (int i = 0; i < n; i++) { left[i] = lf[i]; right[i] = rg[i]; } return root; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...