Submission #61944

# Submission time Handle Problem Language Result Execution time Memory
61944 2018-07-27T06:00:44 Z koosaga(#1793) popa (BOI18_popa) C++11
0 / 100
13 ms 472 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;
	int cur_root = 0;
	stack<int> stk;
	stk.push(0);
	for(int i=1; i<N; i++){
		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 stk.pop();
		}
		if(stk.empty()){
			l[i] = cur_root;
			cur_root = i;
			stk.push(cur_root);
		}
		else{
			r[stk.top()] = i;
		}
	}
	return cur_root;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB not a valid binary tree
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 376 KB not a valid binary tree
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 472 KB not a valid binary tree
2 Halted 0 ms 0 KB -