Submission #380856

# Submission time Handle Problem Language Result Execution time Memory
380856 2021-03-23T10:16:41 Z VodkaInTheJar popa (BOI18_popa) C++14
0 / 100
1000 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);
	par[last] = -1; 
	
	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 89 ms 364 KB too many queries
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 171 ms 364 KB too many queries
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3041 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -