Submission #59763

# Submission time Handle Problem Language Result Execution time Memory
59763 2018-07-23T05:15:18 Z model_code popa (BOI18_popa) C++17
100 / 100
134 ms 628 KB
#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 time Memory Grader output
1 Correct 12 ms 248 KB Output is correct
2 Correct 14 ms 308 KB Output is correct
3 Correct 21 ms 472 KB Output is correct
4 Correct 13 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 552 KB Output is correct
2 Correct 125 ms 552 KB Output is correct
3 Correct 54 ms 552 KB Output is correct
4 Correct 89 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 134 ms 624 KB Output is correct
2 Correct 99 ms 624 KB Output is correct
3 Correct 93 ms 624 KB Output is correct
4 Correct 134 ms 628 KB Output is correct