Submission #73134

#TimeUsernameProblemLanguageResultExecution timeMemory
73134KmcodeRoller Coaster Railroad (IOI16_railroad)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; //#include "railroad.h" vector<pair<int,pair<int,int> > > v; map<int,int> same; set<pair<int,int> > s; int nex(int id){ } long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); for(int i=0;i<n;i++){ if(s[i]==t[i]){ v.push_back(make_pair(s[i],make_pair(1,i) ) ); continue; } v.push_back(make_pair(s[i],make_pair(2,i) ) ); v.push_back(make_pair(t[i],make_pair(0,i) ) ); } sort(v.begin(),v.end()); bool ok=false; int stk=0; int en=0; while( v.size() ) { auto f=v.back(); v.pop_back(); if(f.second.first==2){ s.insert(make_pair(t[f.second.second],f.second.second)); stk++; } else{ if(f.second.first==1){ v.push_back(make_pair(f.first,make_pair(2,f.second.second) ) ); v.push_back(make_pair(f.first,make_pair(0,f.second.second) ) ); continue; } if(stk){ stk--; continue; } if(stk==0){ if(en==0){ en=1; continue; } ok=true; break; } } } return ok; } int main() { int n; assert(1 == scanf("%d", &n)); std::vector<int> s(n), t(n); for (int i = 0; i < n; ++i) assert(2 == scanf("%d%d", &s[i], &t[i])); long long ans = plan_roller_coaster(s, t); printf("%lld\n", ans); return 0; }

Compilation message (stderr)

railroad.cpp: In function 'int nex(int)':
railroad.cpp:12:2: warning: no return statement in function returning non-void [-Wreturn-type]
  }
  ^
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:32:59: error: no matching function for call to 'std::vector<int>::insert(std::pair<int, int>)'
     s.insert(make_pair(t[f.second.second],f.second.second));
                                                           ^
In file included from /usr/include/c++/7/vector:69:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from railroad.cpp:1:
/usr/include/c++/7/bits/vector.tcc:114:5: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::value_type = int]
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/vector.tcc:114:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from railroad.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:1042:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::value_type = int]
       insert(const_iterator __position, value_type&& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:1042:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_vector.h:1059:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]
       insert(const_iterator __position, initializer_list<value_type> __l)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:1059:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_vector.h:1084:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]
       insert(const_iterator __position, size_type __n, const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:1084:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/7/bits/stl_vector.h:1128:2: note: candidate: template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]
  insert(const_iterator __position, _InputIterator __first,
  ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:1128:2: note:   template argument deduction/substitution failed:
railroad.cpp:32:59: note:   candidate expects 3 arguments, 1 provided
     s.insert(make_pair(t[f.second.second],f.second.second));
                                                           ^