제출 #957280

#제출 시각아이디문제언어결과실행 시간메모리
957280duckindogAliens (IOI16_aliens)C++17
4 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; #ifndef LOCAL #include "aliens.h" #endif struct Line { long long a, b; double x(const auto& rhs) { return 1.0 * (rhs.b - b) / (a - rhs.a); }; }; long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) { using pii = pair<int, int>; vector<pii> p(n); for (int i = 0; i < n; ++i) { if (r[i] > c[i]) swap(r[i], c[i]); p[i] = {r[i], c[i]}; } auto dis = [&](pii a) { return abs(a.first - a.second) + 1; }; sort(p.begin(), p.end(), [&](const auto& a, const auto& b) { return dis(a) < dis(b); }); vector<bool> mk(n, true); for (int i = 0; i < n; ++i) { if (!mk[i]) continue; for (int j = 0; j < i; ++j) if (mk[j] && j != i) { if (p[i].first <= p[j].first && p[j].second <= p[i].second) mk[j] = false; } } int cnt = 0; for (int i = 0; i < n; ++i) { cnt += mk[i]; if (mk[i]) p.push_back(p[i]); } p.erase(p.begin(), p.begin() + n); p.push_back({-1, -1}); k = min(k, n = cnt); vector<vector<long long>> f(k + 1, vector<long long>(n + 1, 1e15)); sort(p.begin(), p.end(), [&](const auto& a, const auto& b) { return a.first < b.first; }); f[0][0] = 0; for (int i = 1; i <= k; ++i) { vector<Line> hull; for (int j = 1; j <= n; ++j) { int pl = -p[j].first + 1; long long pre = max(0, p[j - 1].second + pl); pre *= pre; Line line = {2 * pl, f[i - 1][j - 1] + pl * pl - pre}; while (hull.size() > 1 && hull.end()[-2].x(hull.end()[-1]) < hull.end()[-2].x(line)) hull.pop_back(); hull.push_back(line); auto cal = [&](int it) { const auto& [a, b] = hull[it]; long long x = p[j].second; return a * x + b + x * x; }; int l = 0, r = hull.size() - 2, it = 0; while (l <= r) { int mid = l + r >> 1; if (cal(mid) >= cal(mid + 1)) l = it = mid + 1; else r = mid - 1; } f[i][j] = cal(it); } } return f[k][n]; } #ifdef LOCAL int32_t main() { cin.tie(0)->sync_with_stdio(0); int n, m, k; cin >> n >> m >> k; vector<int> r(n), c(n); for (int i = 0; i < n; ++i) cin >> r[i] >> c[i]; cout << take_photos(n, m, k, r, c) << "\n"; } #endif

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

aliens.cpp:11:18: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   11 |   double x(const auto& rhs) { return 1.0 * (rhs.b - b) / (a - rhs.a); };
      |                  ^~~~
aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:64:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   64 |         int mid = l + r >> 1;
      |                   ~~^~~
#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...