Submission #61948

# Submission time Handle Problem Language Result Execution time Memory
61948 2018-07-27T06:09:07 Z koosaga(#1793) popa (BOI18_popa) C++11
100 / 100
137 ms 664 KB
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
typedef pair<int, int> pi;
typedef long long lint;

int solve(int N, int *l, int *r){
	for(int i=0; i<N; i++) l[i] = r[i] = -1;
	stack<int> stk;
	stk.push(0);
	for(int i=1; i<N; i++){
		int son = -1;
		while(!stk.empty()){
			int pos = stk.top();
			while(l[pos] != -1) pos = l[pos];
			if(query(pos, i, stk.top(), stk.top()) == 1){
				break;
			}
			else{
				son = stk.top();
				stk.pop();
			}
		}
		if(!stk.empty()) r[stk.top()] = i;
		l[i] = son;
		stk.push(i);
	}
	while(stk.size() > 1) stk.pop();
	return stk.top();
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 248 KB Output is correct
2 Correct 8 ms 308 KB Output is correct
3 Correct 17 ms 344 KB Output is correct
4 Correct 16 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 118 ms 496 KB Output is correct
2 Correct 137 ms 624 KB Output is correct
3 Correct 55 ms 624 KB Output is correct
4 Correct 78 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 624 KB Output is correct
2 Correct 125 ms 664 KB Output is correct
3 Correct 119 ms 664 KB Output is correct
4 Correct 74 ms 664 KB Output is correct