답안 #149912

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149912 2019-09-01T07:23:02 Z 채원♡예나(#3706, rhrnald, ohjw420, chris2tg) 로카히아 유적 (FXCUP4_lokahia) C++17
컴파일 오류
0 ms 0 KB
#include "lokahia.h"
#include <vector>
#include <queue>
using namespace std;

int h[300];
int sz[300];
typedef pair<int,int> pii;
vector<int> q,nq;
vector<int> Q;

vector<int> lft;
bool merge(int x, int y) {
	int t;
	if(h[x]==h[y]) t=h[x];
	else t=CollectRelics(h[x],h[y]);
	if(t<0) return false;
	h[x]=t;
	sz[x]+=sz[y];
	return true;
}
int FindBase(int N){ int n=N;
	for(int i=0; i<n; i++) q.push_back(i), h[i]=i, sz[i]=1;
	for(int i=0; i<15; i++) {
		nq.clear();
		for(int i=0; i<(int)q.size(); i+=2) {
			if(i==(int)q.size()-1) {
				lft.push_back(q[i]);
			}
			if(merge(q[i], q[i+1])) {
				nq.push_back(q[i]);
			} else {
				Q.push_back(q[i]);
				Q.push_back(q[i+1]);
			}
		}
		q=nq;
	}
	if(lft.empty()) return -1;

	int X=lft.back().first;
	for(int i=0; i<(int)lft.size()-1; i++) merge(X, lft[i]);
	for(int i=0; i<(int)Q.size(); i++) merge(X, Q[i]);
	if(sz[X]>(n/2)) return h[X];
	else return -1;
}

Compilation message

lokahia.cpp: In function 'int FindBase(int)':
lokahia.cpp:41:19: error: request for member 'first' in 'lft.std::vector<int>::back()', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
  int X=lft.back().first;
                   ^~~~~