제출 #1334309

#제출 시각아이디문제언어결과실행 시간메모리
1334309yc11A Difficult(y) Choice (BOI21_books)C++20
컴파일 에러
0 ms0 KiB
#include "books.h"
void solve(int N, int K, long long A, int S) {
    long long a = 1;
    long long b = N;
    vector<int> n1;
    vector<int> pre;
    n1.resize(N);
    while (a<b){
        long long x = (a+b)/2;
        n1[x-1] = skim(x);
        if (n1[x-1]>=A) b = x;
        else a = x+1;
    }

    int ans = n1[b];
    for (int i = 0;i<K-1;i++){
        n1[i] = skim(i+1);
        ans = ans+n1[i];
    }
    if (ans<2*A and ans>A){
        vector<int> a;
        a.push_back(b);
        for (int i = 0;i<K-1;i++) a.push_back(i+1);
        answer(a);
        return;
    }

    int b1 = b;
    ans = ans-n1[b-1];


    n1[K-1] = skim(K);
    ans = ans+n1[K-1];
    int c = 0;
    b--;

    while (ans<A){
        ans = ans-n1[c]+skim(b+1);

        c++;
        b--;
    }
    if (ans>=A){
        vector<int> a;
        for (int i = c;i<K;i++) a.push_back(i+1);
        for (int i = b+1;i<b1;i++) a.push_back(i+1);
        answer(a);
        return;

    }
    impossible();





}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:5:5: error: 'vector' was not declared in this scope
    5 |     vector<int> n1;
      |     ^~~~~~
books.cpp:5:5: note: suggested alternatives:
In file included from /usr/include/c++/13/vector:66,
                 from books.h:4,
                 from books.cpp:1:
/usr/include/c++/13/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/13/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
books.cpp:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> n1;
      |            ^~~
books.cpp:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> pre;
      |            ^~~
books.cpp:7:5: error: 'n1' was not declared in this scope
    7 |     n1.resize(N);
      |     ^~
books.cpp:21:16: error: expected primary-expression before 'int'
   21 |         vector<int> a;
      |                ^~~
books.cpp:22:11: error: request for member 'push_back' in 'a', which is of non-class type 'long long int'
   22 |         a.push_back(b);
      |           ^~~~~~~~~
books.cpp:23:37: error: request for member 'push_back' in 'a', which is of non-class type 'long long int'
   23 |         for (int i = 0;i<K-1;i++) a.push_back(i+1);
      |                                     ^~~~~~~~~
books.cpp:24:16: error: could not convert 'a' from 'long long int' to 'std::vector<int>'
   24 |         answer(a);
      |                ^
      |                |
      |                long long int
books.cpp:44:16: error: expected primary-expression before 'int'
   44 |         vector<int> a;
      |                ^~~
books.cpp:45:35: error: request for member 'push_back' in 'a', which is of non-class type 'long long int'
   45 |         for (int i = c;i<K;i++) a.push_back(i+1);
      |                                   ^~~~~~~~~
books.cpp:46:38: error: request for member 'push_back' in 'a', which is of non-class type 'long long int'
   46 |         for (int i = b+1;i<b1;i++) a.push_back(i+1);
      |                                      ^~~~~~~~~
books.cpp:47:16: error: could not convert 'a' from 'long long int' to 'std::vector<int>'
   47 |         answer(a);
      |                ^
      |                |
      |                long long int