답안 #908391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908391 2024-01-16T11:46:13 Z penguin133 도서관 (JOI18_library) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
 
void Solve(int N){
  if(N == 2)return {1, 2};
	int A[N+1];
	for(int i=1;i<=N;i++)A[i] = 0;
	vector<int>v;
	for(int i=1;i<=N;i++)v.push_back(1);
	vector<int>fin;
	for(int i=1;i<=N;i++){
		v[i-1] = 0;
		int ans = Query(v);
		if(ans == 1){fin.push_back(i), A[i] = 1; break;}
		v[i-1] = 1;
	}
	for(int i=2;i<=N;i++){
		int x = fin.back();
		v.clear();
		for(int k=0;k<N;k++)v.push_back(0);
		v[x-1] = 1;
		int lo = 1, hi = N;
		while(lo < hi){
			int mid = (lo + hi) >> 1;
			for(int i=0;i<N;i++)v[i] = 0;
			int cnt = 0;
			for(int j = lo; j <= mid; j++){
				if(A[j])continue;
				v[j - 1] = 1;
				cnt++;
			}
			if(cnt == 0){
				lo = mid + 1;
				continue;
			}
			v[x-1] = 1;
			int tmp = Query(v);
			v[x-1] = 0;
			int tmp2 = Query(v);
			//cout << lo << ' ' << mid << ' ' << tmp << ' ' << tmp2 << '\n';
			if(tmp > tmp2)lo = mid + 1;
			else hi = mid;
		}
		//cout << lo << ' ';
		fin.push_back(lo);
		A[lo] = 1;
	}
	Answer(fin);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:6:25: error: return-statement with a value, in function returning 'void' [-fpermissive]
    6 |   if(N == 2)return {1, 2};
      |                         ^