제출 #274935

#제출 시각아이디문제언어결과실행 시간메모리
274935ggoorooAliens (IOI16_aliens)C++14
0 / 100
10 ms640 KiB
#include "aliens.h" #include<iostream> #include<cstdio> #include<algorithm> #define N 4005 #define F first #define S second typedef long long ll; using namespace std; ll i, j, M, d[N][N]; struct st { ll ri, ci, z; } a[N]; bool comp(st p, st q) { return p.ci < q.ci; } long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { ll i, j, w, pl, ans, t1, t2, en, mn; for (i = n; i >= 1; i--) { r[i] = r[i - 1]; c[i] = c[i - 1]; } for (i = 1; i <= n; i++) { r[i]++; c[i]++; if (r[i] > c[i]) swap(r[i], c[i]); a[i].ri = r[i]; a[i].ci = c[i]; a[i].z = i; } a[0].ri = a[0].ci = a[0].z = 0; sort(a + 1, a + n + 1, comp); M = m * m; for (i = 0; i <= n; i++) { en = i; if (k < i) en = k; for (j = 0; j <= en;j++) d[i][j] = M; } ans = M; d[0][0] = 0; for (i = 1; i <= n; i++) { en = i; if (k < i) en = k; for (j = 1; j <= en; j++) { d[i][j] = M; mn = a[i].ri; for (w = i - 1; w >= j - 1; w--) { t1 = a[w].ci; t2 = mn; pl = max(t1 - t2 + 1, 0ll); d[i][j] = min(d[i][j], d[w][j - 1] - pl * pl + (a[i].ci - mn + 1) * (a[i].ci - mn + 1)); if (a[w].ri < mn) mn = a[w].ri; } if (i == n) ans = min(ans, d[i][j]); } } return ans; }
#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...