Submission #521393

#TimeUsernameProblemLanguageResultExecution timeMemory
521393pokmui9909Aliens (IOI16_aliens)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using lf = long double; #define x first #define y second ll N, M, K; pair<ll, ll> A[100005]; ll L[100005]; ll R[100005]; pair<ll, ll> D[100005]; void init(){ sort(A + 1, A + N + 1, [&](pair<ll, ll> a, pair<ll, ll> b) -> bool{ if(a.y != b.y) return a.y < b.y; else return a.x > b.x; }); vector<pair<ll, ll>> B; for(int i = 1; i <= N; i++){ while(B.size() && B.back().x >= A[i].x) B.pop_back(); B.push_back(A[i]); } for(int i = 0; i < B.size(); i++){ L[i + 1] = B[i].x, R[i + 1] = B[i].y; } N = B.size(); } struct Line{ ll a, b, i; ll f(ll x){ return a * x + b; } }; lf X_cross(Line f, Line g){ return 1.0 * (f.b - g.b) / (g.a - f.a); } ll f(ll v){ deque<Line> dq; dq.push_back({-4 * L[1], 2 * L[1] * L[1], 0}); for(int i = 1; i <= N; i++){ while(dq.size() >= 2 && dq[0].f(R[i] + 1) >= dq[1].f(R[i] + 1)) dq.pop_front(); D[i].x = dq[0].f(R[i] + 1) + (R[i] + 1) * (R[i] + 1) * 2 + v; D[i].y = dq[0].i + 1; Line f = {-4 * L[i + 1], D[i].x - max(0LL,R[i]-L[i+1]+1)*max(0LL,R[i]-L[i+1]+1)*2 + L[i+1]*L[i+1]*2, D[i].y}; while(dq.size() >= 2 && X_cross(f, dq[dq.size() - 2]) >= X_cross(f, dq[dq.size() - 1])) dq.pop_back(); dq.push_back(f); } return D[N].y; } int main(){ cin.tie(0) -> sync_with_stdio(false); cin >> N >> M >> K; for(int i = 1; i <= N; i++){ cin >> A[i].x >> A[i].y; A[i].x++; A[i].y++; if(A[i].x > A[i].y){ swap(A[i].x, A[i].y); } } init(); ll S = 0, E = 1e12 + 7; while(S <= E){ ll m = (S + E) / 2; if(f(m * 2) <= K) E = m - 1; else S = m + 1; } f(S * 2); cout << (D[N].x - S * K) / 2; }

Compilation message (stderr)

aliens.cpp: In function 'void init()':
aliens.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < B.size(); i++){
      |                    ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccKcipWi.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctx1NJi.o:aliens.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccKcipWi.o: in function `main':
grader.cpp:(.text.startup+0xf0): undefined reference to `take_photos(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status