Submission #153987

# Submission time Handle Problem Language Result Execution time Memory
153987 2019-09-17T16:19:39 Z karma Library (JOI18_library) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
//#include "library.h"
#define pb      emplace_back
#define ll      long long

using namespace std;

const int N = int(2e3) + 7;

vector<int> m, ans, s;
int low, high, mid, sz, cur;

void Solve(int n) {
    if(n == 1) {Answer({1}); return;}
    m.resize(n, 1); s.resize(n);
    for(int i = 0; i < n; ++i) {
       m[i] = 0;
       if(Query(m) == 1) {cur = i; break;}
       m[i] = 1;
    }
    iota(s.begin(), s.end(), 0);
    ans.pb(cur + 1);
    s.erase(find(s.begin(), s.end(), cur));
    while(s.size() < n) {
       low = 0, high = s.size() - 1;
       while(low <= high) {
           mid = sz = (low + high) >> 1;
           fill(m.begin(), m.end(), 0);
           for(int x: s) {
              m[x] = 1;
              if(!sz) break;
              --sz;
           }
           int res = Query(m);
           m[cur] = 1;
           if(res == Query(m)) high = mid - 1;
           else low = mid + 1;
       }
       cur = s[low];
       ans.pb(cur + 1);
       s.erase(find(s.begin(), s.end(), cur));
    }
    Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:14:17: error: 'Answer' was not declared in this scope
     if(n == 1) {Answer({1}); return;}
                 ^~~~~~
library.cpp:18:11: error: 'Query' was not declared in this scope
        if(Query(m) == 1) {cur = i; break;}
           ^~~~~
library.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(s.size() < n) {
           ~~~~~~~~~^~~
library.cpp:34:22: error: 'Query' was not declared in this scope
            int res = Query(m);
                      ^~~~~
library.cpp:43:5: error: 'Answer' was not declared in this scope
     Answer(ans);
     ^~~~~~