제출 #597638

#제출 시각아이디문제언어결과실행 시간메모리
597638cheissmartAliens (IOI16_aliens)C++14
41 / 100
2067 ms5332 KiB
#include "aliens.h" #include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7; const ll oo = 1e18; struct DS { struct line { ll m, b; int id; line(ll _m, ll _b, int _id) { m = _m, b = _b, id = _id; } ll operator () (ll x) { return m * x + b; } }; V<line> tt; void insert(ll m, ll b, int id) { tt.EB(m, b, id); } int qry(ll x) { ll mn = oo; int res = -1; for(line l:tt) if(l(x) < mn){ mn = l(x); res = l.id; } return res; } }; long long take_photos(int n, int C, int k, vi r, vi c) { V<pi> a; for(int i = 0; i < n; i++) { int x = r[i] + c[i], y = abs(r[i] - c[i]); a.EB(x, y); } sort(ALL(a)); auto cover = [&] (pi x, pi y) { return abs(x.F - y.F) <= x.S - y.S; }; V<pi> stk; for(pi p:a) { if(SZ(stk) && cover(stk.back(), p)) continue; while(SZ(stk) && cover(p, stk.back())) stk.pop_back(); stk.PB(p); } a = stk; n = SZ(a); auto intersect = [&] (int i) -> ll { if(i == 0) return 0; if(a[i].F - a[i - 1].F > a[i - 1].S + a[i].S) return 0; int d = (a[i - 1].S - a[i].S + a[i].F - a[i - 1].F) / 2; return 1LL * (a[i - 1].S - d + 1) * (a[i - 1].S - d + 1); }; auto go = [&] (ll x) -> pair<ll, int> { V<ll> dp(n + 1); vi take(n + 1); auto get_f = [&] (int j) -> pair<ll, ll> { int bj = (a[j].F + a[j].S) / 2; int cj = a[j].S - bj + 1; ll mj = 2LL * cj; ll kj = dp[j] - intersect(j) + x + 1LL * cj * cj; return {mj, kj}; }; DS ds; for(int i = 1; i <= n; i++) { { auto[m, b] = get_f(i - 1); ds.insert(m, b, i - 1); } int bi = (a[i - 1].F + a[i - 1].S) / 2; dp[i] = oo; int j = ds.qry(bi); auto[m, b] = get_f(j); dp[i] = m * bi + b + 1LL * bi * bi; take[i] = take[j] + 1; } return {dp[n], take[n]}; }; { auto[val, take] = go(0); if(take <= k) return val; } ll lb = 0, rb = ll(1e12) + 1; while(lb <= rb) { ll mb = (lb + rb) / 2; auto[val, take] = go(mb); if(take <= k) { rb = mb - 1; } else { lb = mb + 1; } } auto[val, take] = go(lb); return val - lb * k; }

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In lambda function:
aliens.cpp:89:21: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   89 |                 auto[m, b] = get_f(i - 1);
      |                     ^
aliens.cpp:96:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   96 |             auto[m, b] = get_f(j);
      |                 ^
aliens.cpp: In function 'long long int take_photos(int, int, int, vi, vi)':
aliens.cpp:104:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  104 |         auto[val, take] = go(0);
      |             ^
aliens.cpp:111:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  111 |         auto[val, take] = go(mb);
      |             ^
aliens.cpp:118:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  118 |     auto[val, take] = go(lb);
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...