Submission #1334313

#TimeUsernameProblemLanguageResultExecution timeMemory
1334313yc11A Difficult(y) Choice (BOI21_books)C++20
Compilation error
0 ms0 KiB
#include "books.h"
#include <vector>
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> a1;
        a1.push_back(b);
        for (int i = 0;i<K-1;i++) a1.push_back(i+1);
        answer(a1);
        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> a1;
        for (int i = c;i<K;i++) a1.push_back(i+1);
        for (int i = b+1;i<b1;i++) a1.push_back(i+1);
        answer(a1);
        return;

    }
    impossible();





}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int> n1;
      |     ^~~~~~
books.cpp:6: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:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> n1;
      |            ^~~
books.cpp:7:12: error: expected primary-expression before 'int'
    7 |     vector<int> pre;
      |            ^~~
books.cpp:8:5: error: 'n1' was not declared in this scope
    8 |     n1.resize(N);
      |     ^~
books.cpp:22:16: error: expected primary-expression before 'int'
   22 |         vector<int> a1;
      |                ^~~
books.cpp:23:9: error: 'a1' was not declared in this scope; did you mean 'a'?
   23 |         a1.push_back(b);
      |         ^~
      |         a
books.cpp:45:16: error: expected primary-expression before 'int'
   45 |         vector<int> a1;
      |                ^~~
books.cpp:46:33: error: 'a1' was not declared in this scope; did you mean 'b1'?
   46 |         for (int i = c;i<K;i++) a1.push_back(i+1);
      |                                 ^~
      |                                 b1
books.cpp:47:36: error: 'a1' was not declared in this scope; did you mean 'b1'?
   47 |         for (int i = b+1;i<b1;i++) a1.push_back(i+1);
      |                                    ^~
      |                                    b1
books.cpp:48:16: error: 'a1' was not declared in this scope; did you mean 'b1'?
   48 |         answer(a1);
      |                ^~
      |                b1