제출 #777036

#제출 시각아이디문제언어결과실행 시간메모리
7770361binAliens (IOI16_aliens)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #include "aliens.h" using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const ll NMAX = 5e5 + 5; ll n, x, y, bx = -1, dp[NMAX]; vector<pair<int, int>> tmp, v; ll m[NMAX], p[NMAX], sz, ii, cnt[NMAX]; int cross(int a, int b) { return 1.0 *(p[b] - p[a]) / (m[a] - m[b]); } int bad(int a, int b, int c){ return (p[b] - p[a]) * (m[b] - m[c]) >= (m[a] - m[b]) * (p[c] - p[b]);} ll get(int i, ll x){return m[i] * x + p[i];} void upd(ll mm, ll pp, int c){ m[sz] = mm; p[sz] = pp; cnt[sz] = c; while(sz > 1 && bad(sz - 2, sz - 1, sz)){ m[sz - 1] = m[sz]; p[sz - 1] = p[sz]; cnt[sz - 1] = cnt[sz]; if(--sz == ii) ii--; } sz++; return; } ll f(ll x){ while(ii + 1 < sz && get(ii, x) > get(ii + 1, x)) ii++; return get(ii, x); } int go(ll cost){ sz = ii = 0; auto&[x, y] = v[0]; upd(-2 * x, x * x + cost, 0); for(int i = 1; i <= n; i++){ auto&[x, y] = v[i - 1]; dp[i] = f(y + 1) + (y + 1) * (y + 1); if(i < n){ ll xx = v[i].first; ll dy = max(y + 1LL - xx, 0LL); upd(-2 * xx, xx * xx - dy * dy + dp[i] + cost, cnt[ii] + 1); } } //cout << cost << ' ' << cnt[sz - 1] << ' ' << dp[n] << '\n'; return cnt[ii + 1]; } ll take_photos(int n_, int m, int k, vector<int> Y, vector<int> X) { n = n_; for(int i = 0; i < n; i++){ y = Y[i]; x = X[i]; if(x > y) swap(x, y); tmp.emplace_back(x, y); } sort(all(tmp)); for(auto& [x, y] : tmp){ if(x == bx) v.pop_back(); if(v.empty() || v.back().second < y) v.emplace_back(x, y); bx = x; } n = v.size(); ll l = 0, r = 1LL * m * m, mid; while(l < r){ mid = (l + r) / 2; if(go(mid) <= k) r = mid; else l = mid + 1; } go(l); return dp[n] - l * k; } /* int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> X(n), Y(n); for(int& x : X) cin >> x; for(int& y : Y) cin >> y; cout << take_photos(n, m, k, X, Y); return 0; } */

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

aliens.cpp: In function 'int go(ll)':
aliens.cpp:38:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   38 |     auto&[x, y] = v[0];
      |          ^
aliens.cpp:41:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   41 |         auto&[x, y] = v[i - 1];
      |              ^
aliens.cpp: In function 'll take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:61:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   61 |     for(auto& [x, y] : tmp){
      |               ^
#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...