Submission #1220933

#TimeUsernameProblemLanguageResultExecution timeMemory
1220933PotatoManOvertaking (IOI23_overtaking)C++17
Compilation error
0 ms0 KiB
#include "overtaking.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; struct Bus { ll arrivalTime; ll pace; int id; }; bool byArrivalThenPace(const Bus &a, const Bus &b) { if (a.arrivalTime == b.arrivalTime) return a.pace < b.pace; return a.arrivalTime < b.arrivalTime; } vector<Bus> buses; vector<ll> stations; int N, M; vector<ll> arrivalTimes_station[1005]; ll computeExpectedArrival(const Bus& b, int j) { return b.arrivalTime + (stations[j] - stations[j - 1]) * b.pace; } void init(int Lp, int Np, vector<ll> Tp, vector<int> Wp, int Xp, int Mp, vector<int> Sp) { buses.clear(); stations = Sp; // Keep only buses with pace >= reserve pace Xp (Filtering) for (int i = 0; i < Np; i++) { if (Wp[i] >= Xp) buses.push_back({Tp[i], Wp[i], i}); } // Add reserve bus buses.push_back({0, Xp, Np}); N = (int)buses.size(); M = Mp; // Simulate station by station for (int j = 1; j < M; j++) { sort(buses.begin(), buses.end(), byArrivalThenPace); ll curMax = 0; vector<ll> arrivalTimes; for (int i = 0; i < N; i++) { ll expected = computeExpectedArrival(buses[i], j); buses[i].arrivalTime = max(expected, curMax); curMax = max(curMax, buses[i].arrivalTime); arrivalTimes.push_back(buses[i].arrivalTime); } arrivalTimes_station[j] = arrivalTimes; } } ll arrival_time(ll Y, int Xp) { ll arrival = Y; ll pace = Xp; for (int j = 1; j < M; j++) { const vector<ll>& arrTimes = arrivalTimes_station[j]; // Find first bus arriving strictly after current arrival int pos = upper_bound(arrTimes.begin(), arrTimes.end(), arrival) - arrTimes.begin(); // Blocking bus arrival time is last bus arriving <= current arrival ll blockingArrival = (pos == 0) ? 0 : arrTimes[pos - 1]; ll dist = stations[j] - stations[j - 1]; arrival = max(arrival + dist * pace, blockingArrival); } return arrival; }

Compilation message (stderr)

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:30:16: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   30 |     stations = Sp;
      |                ^~
In file included from /usr/include/c++/11/vector:72,
                 from overtaking.h:1,
                 from overtaking.cpp:1:
/usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from overtaking.h:1,
                 from overtaking.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~