Submission #276584

# Submission time Handle Problem Language Result Execution time Memory
276584 2020-08-20T14:02:18 Z super_j6 popa (BOI18_popa) C++14
0 / 100
28 ms 384 KB
#include "popa.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

stack<int> stk;

int qry(int x, int y){
	return query(x, x, min(x, y), max(x, y));
}

int solve(int n, int l[], int r[]){
	for(int i = 0; i < n; i++){
		int x;
		l[i] = r[i] = -1;
		while(!stk.empty() && qry(i, x = stk.top())){
			l[i] = x;
			stk.pop();
		}
		if(!stk.empty()){
			if(!qry(x = stk.top(), i)) return -1;
			r[x] = i;
		}
		stk.push(i);
	}
	return stk.top();
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 256 KB not a valid binary tree
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 384 KB not a valid binary tree
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 256 KB too many queries
2 Halted 0 ms 0 KB -