Submission #1220940

#TimeUsernameProblemLanguageResultExecution timeMemory
1220940PotatoManOvertaking (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<int> 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) { // Reset buses to initial state for this query buses = buses_init; // Set reserve bus departure time for (auto &b : buses) { if (b.id == N - 1) { b.arrivalTime = Y; break; } } 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 'll arrival_time(ll)':
overtaking.cpp:63:13: error: 'buses_init' was not declared in this scope
   63 |     buses = buses_init;
      |             ^~~~~~~~~~
overtaking.cpp:77:65: error: 'arrival' was not declared in this scope
   77 |         int pos = upper_bound(arrTimes.begin(), arrTimes.end(), arrival) - arrTimes.begin();
      |                                                                 ^~~~~~~
overtaking.cpp:83:40: error: 'pace' was not declared in this scope
   83 |         arrival = max(arrival + dist * pace, blockingArrival);
      |                                        ^~~~
overtaking.cpp:85:12: error: 'arrival' was not declared in this scope
   85 |     return arrival;
      |            ^~~~~~~