Submission #744331

#TimeUsernameProblemLanguageResultExecution timeMemory
744331baneTeams (IOI15_teams)C++17
Compilation error
0 ms0 KiB
#include "teams.h" #include "bits/stdc++.h" using namespace std; vector<pair<int,int>> intervals; void init(int N, int A[], int B[]) { intervals.resize(N); for (int i = 0; i < N; ++i) intervals = {A[i], B[i]}; sort(intervals.begin(), intervals.end()); } int can(int M, int K[]) { sort(K, K + M); priority_queue<int, vi, greater<int>> pq; // b : end of interval int idx = 0; for (int i = 0; i < M; ++i) { int todo = K[i]; while (idx < (int)intervals.size() && intervals[idx].first <= K[i]) pq.push(intervals[idx++].second); while (todo) { if (pq.empty()) return 0; if (pq.top() >= K[i]) --todo; pq.pop(); } } return 1; }

Compilation message (stderr)

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:11:26: error: no match for 'operator=' (operand types are 'std::vector<std::pair<int, int> >' and '<brace-enclosed initializer list>')
   11 |   intervals = {A[i], B[i]};
      |                          ^
In file included from /usr/include/c++/10/vector:72,
                 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 teams.cpp:3:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 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 teams.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
teams.cpp: In function 'int can(int, int*)':
teams.cpp:18:22: error: 'vi' was not declared in this scope
   18 |  priority_queue<int, vi, greater<int>> pq; // b : end of interval
      |                      ^~
teams.cpp:18:37: error: template argument 2 is invalid
   18 |  priority_queue<int, vi, greater<int>> pq; // b : end of interval
      |                                     ^~
teams.cpp:24:7: error: request for member 'push' in 'pq', which is of non-class type 'int'
   24 |    pq.push(intervals[idx++].second);
      |       ^~~~
teams.cpp:27:11: error: request for member 'empty' in 'pq', which is of non-class type 'int'
   27 |    if (pq.empty())
      |           ^~~~~
teams.cpp:29:11: error: request for member 'top' in 'pq', which is of non-class type 'int'
   29 |    if (pq.top() >= K[i])
      |           ^~~
teams.cpp:31:7: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   31 |    pq.pop();
      |       ^~~