답안 #380855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
380855 2021-03-23T10:16:20 Z VodkaInTheJar popa (BOI18_popa) C++14
컴파일 오류
0 ms 0 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;
	par[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; 
}

Compilation message

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:11:2: error: 'par' was not declared in this scope
   11 |  par[last] = -1;
      |  ^~~