답안 #221847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221847 2020-04-11T09:26:07 Z patrikpavic2 도서관 (JOI18_library) C++17
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <vector>
#include "library.h"

#define PB push_back

using namespace std;

typedef vector < int > vi;

int n;

bool provjeri(vi skp, int x){
	vi glp(n);
	for(int y : skp)
		glp[y] = 1;
	int ans1 = Query(glp);
	glp[x] = 1;
	int ans2 = Query(glp);
	return ans1 == ans2;
}

int pocetak(){
	vi glp(n);
	for(int i = 0;i < n;i++)
		glp[i] = 1;
	for(int i = 0;i < n;i++){
		glp[i] = 0;
		if(Query(glp) == 1)
			return i;
		glp[i] = 1;
	}
}

int nadi(vi skp,int x){
	int ret = -1;
	for(int i = 10;i >= 0;i--){
		if((ret + (1 << i)) >= (int)skp.size())
			continue;
		vi tmp;
		for(int j = 0;j <= (ret + (1 << i));j++)
			tmp.PB(skp[j]);
		if(!provjeri(tmp, x))
			ret += (1 << i);
	}
	return skp[ret + 1];
}

void Solve(int nn){
	if(n == 1) return {1};
	n = nn;
	int st = pocetak();
	vi tren, ret;
	ret.PB(st); 
	for(int i = 0;i < n;i++)
		if(st != i) tren.PB(i);
	for(int i = 1;i < n;i++){
		ret.PB(nadi(tren, ret.back()));
		for(int j = 0;j < n - i;j++){
			if(tren[j] == ret.back()){
				tren.erase(tren.begin() + j);
				break;
			}
		}
	}
	for(int &x : ret) x++;
	Answer(ret);
}






Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:50:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
  if(n == 1) return {1};
                      ^
library.cpp: In function 'int pocetak()':
library.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^