# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955929 | Dan4Life | 추월 (IOI23_overtaking) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "overtaking.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const int mxN = (int)1010;
multiset<pair<ll,int>> S[mxN];
int l, n, m, x;
vector<pair<ll,int>> t;
vi s, w;
void init(int L, int N, vll T, vi W, int X, int M, vi S)
{
l = L, n = N, m = M, x = X; int i = 0;
for(auto u : T) t.pb({u,i}),i++;
for(auto u : S) s.pb(u);
for(auto u : W) w.pb(u);
w.pb(x);
}
ll arrival_time(ll Y){
S[0].clear();
for(auto cur : t)
S[0].insert({cur.first,cur.second});
S[0].insert({Y,n});
for(int i = 0; i < m-1; i++){
S[i+1].clear();
int dis = s[i+1]-s[i], mx = 0, mx2 = 0, mxu = -1, pre=-1;
for(auto cur : S[i]){
auto u = cur.first;
auto ind = cur.second;
auto speed = w[ind];
if(u!=pre) mx = max(mx, mx2);
pre = u;
S[i+1].insert({max(u+dis*speed,mx),ind});
mx2 = max(mx2, u+dis*speed);
}
}
for(auto cur : S[m-1])
if(cur.second==n) return cur.first;
return -1;
}
Compilation message (stderr)
overtaking.cpp: In function 'll arrival_time(ll)': overtaking.cpp:41:46: error: no matching function for call to 'max(long long int, int&)' 41 | S[i+1].insert({max(u+dis*speed,mx),ind}); | ^ In file included from /usr/include/c++/10/vector:60, from overtaking.h:1, from overtaking.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: overtaking.cpp:41:46: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | S[i+1].insert({max(u+dis*speed,mx),ind}); | ^ In file included from /usr/include/c++/10/vector:60, from overtaking.h:1, from overtaking.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: overtaking.cpp:41:46: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | S[i+1].insert({max(u+dis*speed,mx),ind}); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from overtaking.cpp:2: /usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3480 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3480:5: note: template argument deduction/substitution failed: overtaking.cpp:41:46: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | S[i+1].insert({max(u+dis*speed,mx),ind}); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from overtaking.cpp:2: /usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3486 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3486:5: note: template argument deduction/substitution failed: overtaking.cpp:41:46: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | S[i+1].insert({max(u+dis*speed,mx),ind}); | ^ overtaking.cpp:41:52: error: no matching function for call to 'std::multiset<std::pair<long long int, int> >::insert(<brace-enclosed initializer list>)' 41 | S[i+1].insert({max(u+dis*speed,mx),ind}); | ^ In file included from /usr/include/c++/10/set:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from overtaking.cpp:2: /usr/include/c++/10/bits/stl_multiset.h:502:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<long long int, int>]' 502 | insert(const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:502:32: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, int>&'} 502 | insert(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:507:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<long long int, int>]' 507 | insert(value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:507:27: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::multiset<std::pair<long long int, int> >::value_type&&' {aka 'std::pair<long long int, int>&&'} 507 | insert(value_type&& __x) | ~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:532:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<long long int, int>]' 532 | insert(const_iterator __position, const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:532:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_multiset.h:537:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, std::multiset<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<long long int, int>]' 537 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:537:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_multiset.h:551:2: note: candidate: 'template<class _InputIterator> void std::multiset<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >]' 551 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:551:2: note: template argument deduction/substitution failed: overtaking.cpp:41:52: note: candidate expects 2 arguments, 1 provided 41 | S[i+1].insert({max(u+dis*speed,mx),ind}); | ^ In file included from /usr/include/c++/10/set:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from overtaking.cpp:2: /usr/include/c++/10/bits/stl_multiset.h:563:7: note: candidate: 'void std::multiset<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >]' 563 | insert(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:563:43: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<long long int, int> >' 563 | insert(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:583:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::node_type&&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::node_type = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::node_type]' 583 | insert(node_type&& __nh) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:583:26: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::multiset<std::pair<long long int, int> >::node_type&&' {aka 'std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::node_type&&'} 583 | insert(node_type&& __nh) | ~~~~~~~~~~~~^~~~ /usr/include/c++/10/bits/stl_multiset.h:588:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, std::multiset<_Key, _Compare, _Alloc>::node_type&&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::node_type = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::node_type]' 588 | insert(const_iterator __hint, node_type&& __nh) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:588:7: note: candidate expects 2 arguments, 1 provided overtaking.cpp:42:39: error: no matching function for call to 'max(int&, long long int)' 42 | mx2 = max(mx2, u+dis*speed); | ^ In file included from /usr/include/c++/10/vector:60, from overtaking.h:1, from overtaking.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: overtaking.cpp:42:39: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 42 | mx2 = max(mx2, u+dis*speed); | ^ In file included from /usr/include/c++/10/vector:60, from overtaking.h:1, from overtaking.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: overtaking.cpp:42:39: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 42 | mx2 = max(mx2, u+dis*speed); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from overtaking.cpp:2: /usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3480 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3480:5: note: template argument deduction/substitution failed: overtaking.cpp:42:39: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 42 | mx2 = max(mx2, u+dis*speed); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from overtaking.cpp:2: /usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3486 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3486:5: note: template argument deduction/substitution failed: overtaking.cpp:42:39: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 42 | mx2 = max(mx2, u+dis*speed); | ^ overtaking.cpp:33:49: warning: unused variable 'mxu' [-Wunused-variable] 33 | int dis = s[i+1]-s[i], mx = 0, mx2 = 0, mxu = -1, pre=-1; | ^~~