Submission #1326140

#TimeUsernameProblemLanguageResultExecution timeMemory
1326140ppmn_6Boxes with souvenirs (IOI15_boxes)C++20
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #include "boxes.h" using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); // https://codeforces.com/blog/entry/79148 class Timer: chrono::high_resolution_clock { const time_point start_time; public: Timer(): start_time(now()) {} rep elapsed_time() const { return chrono::duration_cast<chrono::milliseconds>(now() - start_time).count(); } } timer; ll delivery(int n, int k, int l, vector<int> v) { deque<ll> pos(n); ll ans = 0; for (int i = 0; i < n; i++) { pos[i] = v[i]; } auto dist = [&] (ll x, ll y) { if (x > y) { swap(x, y); } return min(y - x, l - y + x); }; auto trip = [&] (int x) { ll cur = 0; for (int i = 0; i < x; i++) { if (dist(cur, pos.front()) <= dist(cur, pos.back())) { ans += dist(cur, pos.front()); cur = pos.front(); pos.pop_front(); } else { ans += dist(cur, pos.back()); cur = pos.back(); pos.pop_back(); } } ans += dist(0, cur); }; trip(n % k); for (int i = 0; i < n / k; i++) { trip(k); } return ans; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccAHPO2L.o: in function `main':
grader.c:(.text.startup+0x1e4): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status