# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862177 | 2023-10-17T15:57:43 Z | iskhakkutbilim | parentrises (BOI18_parentrises) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "popa.h" using namespace std; int solve(int N, int* Left, int* Right){ for(int i = 0; i < N; i++) Left[i] = Right[i] = -1; stack<int> st; for(int i = 0; i < N; i++){ int pref = -1; while(!st.empty()){ int First = st.top(); if(query(First, First, First, i)){ Right[First] = i; break; } pref = First; st.pop(); } Left[i] = pref; st.push(i); } if(st.empty()) assert(false); while(st.size() > 1) st.pop(); return st.top(); }