제출 #428432

#제출 시각아이디문제언어결과실행 시간메모리
428432Kevin_Zhang_TWAliens (IOI16_aliens)C++17
0 / 100
2070 ms972 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define pb emplace_back #define AI(i) begin(i), end(i) template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); } template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); } #ifdef KEV #define DE(args...) kout("[ " + string(#args) + " ] = ", args) void kout() { cerr << endl; } template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); } template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; } #else #define DE(...) 0 #define debug(...) 0 #endif const int MAX_N = 300010; const ll inf = 1ll << 55; #include "aliens.h" ll sq(ll v) { return v * v; } long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { for (int i = 0;i < n;++i) { if (r[i] > c[i]) swap(r[i], c[i]); } vector<int> allc(c); allc.pb(-1); sort(AI(allc)), allc.erase(unique(AI(allc)), end(allc)); int g = allc.size(); vector<vector<ll>> dp(g, vector<ll>(k + 1, inf)); fill(AI(dp[0]), 0); auto get_mn = [&](int ql, int qr) { ll ret = inf; for (int i = 0;i < n;++i) { if (ql <= c[i] && c[i] <= qr) chmin(ret, (ll)r[i]); } assert(ret < inf); return ret; }; //debug(AI(allc)); for (int i = 1;i < g;++i) { for (int j = 1;j <= k;++j) { for (int l = 0;l < i;++l) { ll mnc = get_mn(allc[l]+1, allc[i]); ll wid = allc[i] - mnc + 1; ll rep = max<ll>(0, allc[l] - mnc + 1); chmin(dp[i][j], dp[l][j-1] + sq(wid) - sq(rep)); } } } return dp[g-1][k]; }
#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...