답안 #155464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155464 2019-09-28T13:35:29 Z Mercenary 도서관 (JOI18_library) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;

void Solve(int n)
{
    vector<int> res(n);
    vector<int> ask(n , 1);
    int pre = 0;
    vector<int> p(n);
    for(int i = 0 ; i < n ; ++i)p[i] = i;
    auto del = [&](int x){
        p.erase(find(p.begin(),p.end(),x));
    };
    for(int i = 0 ; i < n ; ++i){
        ask[i] = 0;
        if(Query(ask) == 1){
            pre = i;
            break;
        }
        ask[i] = 1;
    }
    del(pre);res[0] = pre;
    if(n == 1)return res;
    for(int i = 1 ; i < n ; ++i){
        int l = 0 , h = (int)p.size() - 1;
        while(l <= h){
            for(int j = 0 ; j < n ; ++j)ask[j] = 0;
            int mid = l + h >> 1;
            for(int j = 0 ; j <= mid ; ++j)ask[p[j]] = 1;
            int last = Query(ask);
            ask[pre] = 1;
            if(last == Query(ask))h = mid - 1;
            else l = mid + 1;
        }
        pre = p[l];
        del(pre);
        res[i] = pre;
    }
    for(int i = 0 ; i < n ; ++i)res[i]++;
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:24:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
     if(n == 1)return res;
                      ^~~
library.cpp:29:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid = l + h >> 1;
                       ~~^~~