Submission #624993

#TimeUsernameProblemLanguageResultExecution timeMemory
624993pirhosigLast supper (IOI12_supper)C++17
Compilation error
0 ms0 KiB
#include "advisor.h" #include <bits/stdc++.h> #define R(a) for (int i = 0; i < a; ++i) #define ii pair<int, int> using namespace std; void ComputeAdvice(int *C, int N, int K, int M) { vector<int> nxt(N, INT_MAX); vector<int> val(N); for (int i = N - 1; i >= 0; --i) { int a = C[i]; val[i] = nxt[a]; nxt[a] = i; } vector<bool> init(K); vector<bool> rem(N); priority_queue<ii> que; R(K) { que.push({nxt[i], i}); } vector<bool> has(N); vector<int> last(N, -1); R(K) { has[i] = true; } R(N) { int a = C[i]; if (!has[a]) { has[a] = true; auto b = que.top(); que.pop(); if (last[b.second] == -1) init[b.second] = true; else rem[last[b.second]] = true; has[b] = false; } last[a] = i; que.push({val[i], a}); } R(K) { if (init[i]) WriteAdvice(1); else WriteAdvice(0); } R(N) { if (rem[i]) WriteAdvice(1); else WriteAdvice(0); } }
#include "assistant.h" #include <bits/stdc++.h> #define R(a) for (int i = 0; i < a; ++i) #define ii pair<int, int> using namespace std; void Assist(unsigned char *A, int N, int K, int R) { queue<int> rem; set<int> val; R(K) { cerr << "A " << (int)(A[i]) << endl; } cerr << "N\n"; R(N) { cerr << "A " << (int)(A[K + i]) << endl; } R(K) { val.insert(i); if (A[i]) rem.push(i); } R(N) { int a = GetRequest(); if (!val.count(a)) { val.insert(a); int b = rem.front(); PutBack(b); val.erase(b); rem.pop(); } if (A[K + i]) rem.push(a); } }

Compilation message (stderr)

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:37:16: error: no match for 'operator[]' (operand types are 'std::vector<bool>' and 'std::pair<int, int>')
   37 |             has[b] = false;
      |                ^
In file included from /usr/include/c++/10/vector:68,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from advisor.cpp:2:
/usr/include/c++/10/bits/stl_bvector.h:909:7: note: candidate: 'std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](std::vector<bool, _Alloc>::size_type) [with _Alloc = std::allocator<bool>; std::vector<bool, _Alloc>::reference = std::vector<bool>::reference; std::vector<bool, _Alloc>::size_type = long unsigned int]'
  909 |       operator[](size_type __n)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_bvector.h:909:28: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<bool>::size_type' {aka 'long unsigned int'}
  909 |       operator[](size_type __n)
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_bvector.h:916:7: note: candidate: 'std::vector<bool, _Alloc>::const_reference std::vector<bool, _Alloc>::operator[](std::vector<bool, _Alloc>::size_type) const [with _Alloc = std::allocator<bool>; std::vector<bool, _Alloc>::const_reference = bool; std::vector<bool, _Alloc>::size_type = long unsigned int]'
  916 |       operator[](size_type __n) const
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_bvector.h:916:28: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<bool>::size_type' {aka 'long unsigned int'}
  916 |       operator[](size_type __n) const
      |                  ~~~~~~~~~~^~~