Submission #1138016

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

stack<int> st;

int solve(int N, int* Left, int* Right) {
    int root = -1;

    for (int i = 0; i < N; i++)
        Left[i] = Right[i] = -1;

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

        if (st.empty()) root = i;
            else Right[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...