제출 #560184

#제출 시각아이디문제언어결과실행 시간메모리
560184Ooops_sorryA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>

using namespace std;

#ifndef LOCAL
    #include books.h
#else
    long long skim(int i) {
        cout << "? " << i << endl;
        int val;
        cin >> val;
        return val;
    }
    void answer(vector<int> v) {
        for (auto to : v) {
            cout << to << ' ';
        }
        cout << endl;
    }
    void impossible() {
        cout << "NO WAY" << endl;
    }
#endif // LOCAL

#define pb push_back
#define ll long long

void solve(int n, int k, ll a, int s) {
    int l = -1, r = n;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        if (skim(mid + 1) >= a) {
            r = mid;
        } else {
            l = mid;
        }
    }
    ll sum = 0;
    vector<int> arr;
    for (int j = 0; j < k - 1; j++) {
        sum += skim(j + 1);
        arr.pb(j + 1);
    }
    vector<int> rem_arr = arr;
    ll val = skim(k), rem_sum = sum;
    sum += val;
    arr.pb(k);
    if (a <= sum && sum <= 2 * a) {
        answer(arr);
        return;
    }
    if (r >= k) {
        vector<int> nw;
        for (int j = 0; j < k; j++) {
            sum -= skim(k - j);
            sum += skim(r - j);
            nw.pb(r - j);
            arr.pop_back();
            if (a <= sum && sum <= 2 * a) {
                for (auto to : nw) arr.pb(to);
                answer(arr);
                return;
            }
        }
    }
    sum = rem_sum, arr = rem_arr;
    if (r < n) {
        if (r >= k - 1) {
            ll valr = skim(r + 1);
            sum += valr;
            if (a <= sum && sum <= 2 * a) {
                arr.pb(r + 1);
                answer(arr);
                return;
            }
        }
    }
    impossible();
}

#ifdef LOCAL
    signed main() {
        int n, k, s;
        long long a;
        cin >> n >> k >> a >> s;
        solve(n, k, a, s);
    }
#endif // LOCAL

컴파일 시 표준 에러 (stderr) 메시지

books.cpp:6:14: error: #include expects "FILENAME" or <FILENAME>
    6 |     #include books.h
      |              ^~~~~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:32:13: error: 'skim' was not declared in this scope
   32 |         if (skim(mid + 1) >= a) {
      |             ^~~~
books.cpp:41:16: error: 'skim' was not declared in this scope
   41 |         sum += skim(j + 1);
      |                ^~~~
books.cpp:45:14: error: 'skim' was not declared in this scope
   45 |     ll val = skim(k), rem_sum = sum;
      |              ^~~~
books.cpp:49:9: error: 'answer' was not declared in this scope
   49 |         answer(arr);
      |         ^~~~~~
books.cpp:61:17: error: 'answer' was not declared in this scope
   61 |                 answer(arr);
      |                 ^~~~~~
books.cpp:66:11: error: 'rem_sum' was not declared in this scope
   66 |     sum = rem_sum, arr = rem_arr;
      |           ^~~~~~~
books.cpp:73:17: error: 'answer' was not declared in this scope
   73 |                 answer(arr);
      |                 ^~~~~~
books.cpp:78:5: error: 'impossible' was not declared in this scope
   78 |     impossible();
      |     ^~~~~~~~~~