Submission #1138018

#TimeUsernameProblemLanguageResultExecution timeMemory
1138018ConquerConquererpopa (BOI18_popa)C++20
0 / 100
5 ms420 KiB
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;

stack<int> st;

int solve(int N, int* L, int* R) {
    while (st.size() > 0) st.pop();
    
    int root = -1;

    for (int i = 0; i < N; i++)
        L[i] = R[i] = -1;

    for (int i = 0; i < N; i++) {
        while (st.size() > 0 && query(st.top(), i, i, i)) {
            R[st.top()] = -1;
            L[i] = st.top();
            st.pop();
        }

        if (st.empty()) root = i;
            else R[st.top()] = i;
        st.push(i);
    }

    return root;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...