Submission #380854

# Submission time Handle Problem Language Result Execution time Memory
380854 2021-03-23T10:15:32 Z VodkaInTheJar popa (BOI18_popa) C++14
0 / 100
201 ms 364 KB
#include <bits/stdc++.h>
#include "popa.h"

using namespace std;


int solve(int n, int *left, int *right)
{
	int last = 0; 
	left[last] = -1, right[last] = -1;
	vector <int> par(n);
	
	for (int i = 1; i < n; i++)
	{
		int prv = last;
		while (last != -1 && !query(last, i, last, last))
		{
			prv = last;
			last = par[last];
		}
		
		if (last == -1)
		{
			par[prv] = i;
			left[i] = prv;
			right[i] = -1; 
		}
		
		else 
		{
			if (right[last] == -1)
			{
				right[last] = i;
				left[i] = -1; 
				right[i] = -1; 
			    par[i] = last; 
			}
			
			else 
			{
				left[i] = right[last];
				par[left[i]] = i;
				right[i] = -1; 
				right[last] = i; 
			}
		}
		
		last = i;
	}
	
	while (par[last] != -1)
	last = par[last];
	
	return last; 
}
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 364 KB too many queries
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 201 ms 364 KB too many queries
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 364 KB too many queries
2 Halted 0 ms 0 KB -