Submission #1162009

#TimeUsernameProblemLanguageResultExecution timeMemory
1162009gelastropodpopa (BOI18_popa)C++20
100 / 100
26 ms424 KiB
#include "popa.h"
#include <bits/stdc++.h>
using namespace std;

int solve(int N, int* Left, int* Right) {
	stack<int> stk;
	for (int i = 0; i < N; i++) {
		Left[i] = -1;
		Right[i] = -1;
	}
	stk.push(0);
	for (int i = 1; i < N; i++) {
		int prev = -1;
		while (!stk.empty() && query(stk.top(), i, i, i)) {
			prev = stk.top();
			stk.pop();
		}
		if (!stk.empty()) {
			Right[stk.top()] = i;
		}
		Left[i] = prev;
		stk.push(i);
	}
	while (stk.size() != 1) {
		stk.pop();
	}
	return stk.top();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...