제출 #1064332

#제출 시각아이디문제언어결과실행 시간메모리
1064332not_amirA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
void solve(int N, int K, long long A, int S) {
    // TODO implement this function
    vector<ll> x(N + 1);
    ll sum = 0;
    for(int i = 1; i <= K; i++)
        sum += x[i] = skim(i);
    if(sum > 2 * A)
        impossible();
    sum -= x[K];
    int l = K + 1, h = N, a = N + 1;
    while(l <= h){
        int mid = (l + h) / 2;
        if(skim(mid) >= A){
            h = mid - 1;
            a = mid;
        }
        else
            l = mid + 1;        
    }
    if(a != N + 1){
        sum += x[a] = skim(a);
        if(sum <= 2 * A){
            vector<int> ans;
            for(int i = 1; i < K; i++)
                ans.push_back(i);
            ans.push_back(a);
            answer(ans);
            return;
        }
    }
    for(int i = 0; i < K; i++)
        x[a - i - 1] = skim(a - i - 1);
    for(int i = 0; i <= K; i++){
        sum = 0;
        vector<int> ans;
        for(int j = 1; j <= K - i; j++){
            sum += x[j];
            ans.push_back(j);
        }
        for(int j = 0; j < i; j++){
            sum += x[a - j - 1];
            ans.push_back(a - j - 1);
        }
        if(sum >= A && sum <= 2*A){
            answer(ans);
            return;
        }
    }
    impossible();
}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:3:5: error: 'vector' was not declared in this scope
    3 |     vector<ll> x(N + 1);
      |     ^~~~~~
books.cpp:3:12: error: 'll' was not declared in this scope
    3 |     vector<ll> x(N + 1);
      |            ^~
books.cpp:3:16: error: 'x' was not declared in this scope
    3 |     vector<ll> x(N + 1);
      |                ^
books.cpp:4:7: error: expected ';' before 'sum'
    4 |     ll sum = 0;
      |       ^~~~
      |       ;
books.cpp:6:9: error: 'sum' was not declared in this scope
    6 |         sum += x[i] = skim(i);
      |         ^~~
books.cpp:6:23: error: 'skim' was not declared in this scope
    6 |         sum += x[i] = skim(i);
      |                       ^~~~
books.cpp:7:8: error: 'sum' was not declared in this scope
    7 |     if(sum > 2 * A)
      |        ^~~
books.cpp:8:9: error: 'impossible' was not declared in this scope
    8 |         impossible();
      |         ^~~~~~~~~~
books.cpp:9:5: error: 'sum' was not declared in this scope
    9 |     sum -= x[K];
      |     ^~~
books.cpp:13:12: error: 'skim' was not declared in this scope
   13 |         if(skim(mid) >= A){
      |            ^~~~
books.cpp:21:23: error: 'skim' was not declared in this scope
   21 |         sum += x[a] = skim(a);
      |                       ^~~~
books.cpp:23:20: error: expected primary-expression before 'int'
   23 |             vector<int> ans;
      |                    ^~~
books.cpp:25:17: error: 'ans' was not declared in this scope
   25 |                 ans.push_back(i);
      |                 ^~~
books.cpp:26:13: error: 'ans' was not declared in this scope
   26 |             ans.push_back(a);
      |             ^~~
books.cpp:27:13: error: 'answer' was not declared in this scope
   27 |             answer(ans);
      |             ^~~~~~
books.cpp:32:24: error: 'skim' was not declared in this scope
   32 |         x[a - i - 1] = skim(a - i - 1);
      |                        ^~~~
books.cpp:35:16: error: expected primary-expression before 'int'
   35 |         vector<int> ans;
      |                ^~~
books.cpp:38:13: error: 'ans' was not declared in this scope
   38 |             ans.push_back(j);
      |             ^~~
books.cpp:42:13: error: 'ans' was not declared in this scope
   42 |             ans.push_back(a - j - 1);
      |             ^~~
books.cpp:45:20: error: 'ans' was not declared in this scope
   45 |             answer(ans);
      |                    ^~~
books.cpp:45:13: error: 'answer' was not declared in this scope
   45 |             answer(ans);
      |             ^~~~~~
books.cpp:49:5: error: 'impossible' was not declared in this scope
   49 |     impossible();
      |     ^~~~~~~~~~