Submission #1042845

#TimeUsernameProblemLanguageResultExecution timeMemory
1042845ZicrusRoller Coaster Railroad (IOI16_railroad)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; typedef long long ll; ll plan_roller_coaster(vector<int> s, vector<int> t) { ll n = s.size(); map<ll, ll> m; for (int i = 0; i < n; i++) { m[s[i]] = t[i]; } ll cur = (*m.begin()).second; m.erase(m.begin()); ll res = 0; while (!m.empty()) { auto iter = lower_bound(m.begin(), m.end(), pair<const ll, ll>(cur, 0)); if (iter == m.end()) return 1; cur = (*iter).second; m[iter] = -1000; } return 0; }

Compilation message (stderr)

railroad.cpp: In function 'll plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:22:10: error: no match for 'operator[]' (operand types are 'std::map<long long int, long long int>' and 'std::_Rb_tree_iterator<std::pair<const long long int, long long int> >')
   22 |         m[iter] = -1000;
      |          ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from railroad.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = long long int]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::_Rb_tree_iterator<std::pair<const long long int, long long int> >' to 'const key_type&' {aka 'const long long int&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = long long int]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::_Rb_tree_iterator<std::pair<const long long int, long long int> >' to 'std::map<long long int, long long int>::key_type&&' {aka 'long long int&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
railroad.cpp:17:8: warning: unused variable 'res' [-Wunused-variable]
   17 |     ll res = 0;
      |        ^~~