Submission #155465

# Submission time Handle Problem Language Result Execution time Memory
155465 2019-09-28T13:36:09 Z Mercenary Library (JOI18_library) C++14
Compilation error
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){
    	Answer(res);
		return;
    }
    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:17:12: error: 'Query' was not declared in this scope
         if(Query(ask) == 1){
            ^~~~~
library.cpp:25:6: error: 'Answer' was not declared in this scope
      Answer(res);
      ^~~~~~
library.cpp:32:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid = l + h >> 1;
                       ~~^~~
library.cpp:34:24: error: 'Query' was not declared in this scope
             int last = Query(ask);
                        ^~~~~
library.cpp:44:2: error: 'Answer' was not declared in this scope
  Answer(res);
  ^~~~~~