제출 #427421

#제출 시각아이디문제언어결과실행 시간메모리
4274212qbingxuanAliens (IOI16_aliens)C++14
0 / 100
2112 ms498388 KiB
#include "aliens.h" #include <bits/stdc++.h> #ifdef local #define debug(x...) qqbx(#x, x) #define pary(x...) danb(#x, x) #define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n" template <typename ...T> void qqbx(const char *s, T ...a) { int cnt = sizeof...(T); ((std::cerr << "\e[1;32m(" << s << ") = ("), ..., (std::cerr << a << (--cnt ? ", " : ")\e[0m\n"))); } template <typename T> void danb(const char *s, T L, T R) { std::cerr << "\e[1;32m[ " << s << " ] = [ "; for (int f = 0; L != R; ++L) std::cerr << (f++ ? ", " : "") << *L; std::cerr << " ]\e[0m\n"; } #else #define debug(...) ((void)0) #define pary(...) ((void)0) #define safe ((void)0) #endif // local #define all(v) begin(v),end(v) using namespace std; using ll = long long; const ll INF = 1e18; void chmin(ll &x, ll v) { if (x > v) x = v; } ll sq(ll x) { return x * x; } long long take_photos(int n, int m, int k, std::vector<int> row, std::vector<int> col) { vector<pair<int,int>> seg; for (int i = 0; i < n; i++) { int l = row[i], r = col[i]; if (l > r) swap(l, r); seg.emplace_back(l, r); } sort(all(seg)); vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(k+1, vector<ll>(n+1, INF))); dp[0][0][0] = 0; for (int i = 0; i < n; i++) { int l = seg[i].first; int r = seg[i].second; int mxpos = i; for (int j = i+1; j <= n; j++) { for (int c = 0; c < k; c++) { for (int a = 0; a <= n; a++) { int lastr = (a ? seg[a-1].second : -1); if (dp[i][c][a] == INF) continue; ll cost = (lastr < l ? sq(r - l + 1) : lastr >= r ? 0 : sq(r - l + 1) - sq(lastr - l + 1)); chmin(dp[j][c+1][mxpos+1], dp[i][c][a] + cost); } } if (j < n) { if (r < seg[j].second) { r = seg[j].second; mxpos = j; } } } } ll mn = INF; for (int a = 0; a <= n; a++) mn = min(mn, dp[n][k][a]); return mn; }
#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...