Submission #59763

#TimeUsernameProblemLanguageResultExecution timeMemory
59763model_codepopa (BOI18_popa)C++17
100 / 100
134 ms628 KiB
#include <bits/stdc++.h>
#include "popa.h"

using namespace std;

int solve(int n, int* left, int* right) {
	vector<int> st;
	int root = -1;
	for (int i = 0; i < n; i++) {
		left[i] = right[i] = -1;
		while (st.size() && query(st.back(), i, i, i)) {
			right[st.back()] = left[i];
			left[i] = st.back();
			st.pop_back();
		}
		if (st.size()) right[st.back()] = i;
		else root = i;
		st.push_back(i);
	}
	return root;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...