Submission #1188491

#TimeUsernameProblemLanguageResultExecution timeMemory
1188491DanielPr8A Difficult(y) Choice (BOI21_books)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include"books.h"
using namespace std;
using ll = __int128_t;
using vll = vector<ll>;
using vvl = vector<vll>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvp = vector<vpl>;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(),v.end()


vll passs;
ll k, a;
ll ski(ll a){
    if(passs[a]==-1)return passs[a]=skim(a);
    return passs[a];
}
void sto(){
    while(true){
        cout << "";
    }
}
void answr(vector<int> id){
    if(id.size()!=k)sto();
    ll ans=0;
    for(ll i:id)ans+=ski(i);
    if(ans>a*2)sto();
    if(ans<a)sto();
    answer(id);
}

void solve(int n, int k1, long long a1, int Q) {
    k=k1;a=a1;
    ll s = 1, e = n, m;
    passs = vll(n+1,-1);
    while(s<e){
        m = (s+e+1)/2;
        ll t = ski(m);
        if(t>a)e=m-1;
        else s=m;
    }
    vll v1(k), v2;
    vector<int> id;
    ll v3=-1;
    for(ll i = 0; i < k; ++i){v1[i] = ski(i+1);}
    for(ll i = max<ll>(1, s-k+1); i <= s; ++i){v2.pb(ski(i));id.pb(i);}
    if(s<n)v3=ski(s+1);
    ll p1=0, p2=0;
    for(ll i:v1)p1+=i;
    for(ll i:v2)p2+=i;
    if(p1>2*a)impossible();
    else if(k<=s){
        if(p2>=a){
            for(ll i = 0; i < k; ++i){
                if(p2<=2*a)break;
                id[i]=i+1;
                p2 += v1[i]-v2[i];
            }
            answer(id);
        }
        else if(s<n){
            iota(all(id),1);
            id.back()=s+1;
            if(p1-v1.back()+v3<=a*2)answer(id);
            else impossible();
        }
        else impossible();
    }
    else{
        id=vll(k);
        iota(all(id),1);
        if(p1>=a)answr(id);
        else impossible();
    }
}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:74:17: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'vll' {aka 'std::vector<__int128>'})
   74 |         id=vll(k);
      |                 ^
In file included from /usr/include/c++/11/vector:72,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<__int128>'} to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<__int128>'} to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<__int128>'} to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~