Submission #254336

#TimeUsernameProblemLanguageResultExecution timeMemory
254336mode149256Aliens (IOI16_aliens)C++14
25 / 100
2075 ms13552 KiB
/*input */ #include <bits/stdc++.h> #include "aliens.h" using namespace std; namespace my_template { typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ld, ld> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ld> vd; typedef vector<ld> vl; typedef vector<vl> vll; typedef vector<pi> vpi; typedef vector<vpi> vpii; typedef vector<pl> vpl; typedef vector<cd> vcd; typedef vector<pd> vpd; typedef vector<bool> vb; typedef vector<vb> vbb; typedef std::string str; typedef std::vector<str> vs; #define x first #define y second #define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n" const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L; template<typename T> pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); } template<typename T> pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); } template<typename T> T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); } template<typename T> T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); } template<typename T> void print(vector<T> vec, string name = "") { cout << name; for (auto u : vec) cout << u << ' '; cout << '\n'; } } using namespace my_template; const int MOD = 1000000007; const ll INF = 1e17; const int MX = 100101; int N, M, K; vpl sk; // y < x void sanitize(vi &r, vi &c) { vpi temp; for (int i = 0; i < N; ++i) { if (r[i] > c[i]) swap(r[i], c[i]); temp.emplace_back(c[i], r[i]); } sort(temp.begin(), temp.end(), [](const pi & a, const pi & b) { return a.x < b.x or (a.x == b.x and a.y > b.y); }); for (int i = 0; i < N; ++i) { while (sk.size() and (int)sk.back().y >= temp[i].y) sk.pop_back(); sk.push_back(temp[i]); } N = (int)sk.size(); sk.insert(sk.begin(), { -1, -1}); // for (auto u : sk) printf("%d %d\n", u.x, u.y); } ll take_photos(int n, int m, int k, vi r, vi c) { N = n; M = m; K = k; sanitize(r, c); vll dp(K + 1, vl(N + 1, INF)); dp[0][0] = 0; for (k = 1; k <= K; ++k) { for (n = 1; n <= N; ++n) { dp[k][n] = dp[k - 1][n]; for (int t = 0; t < n; ++t) { ld newVal = dp[k - 1][t] + (sk[n].x - sk[t + 1].y + 1) * (sk[n].x - sk[t + 1].y + 1) - max(sk[t].x - sk[t + 1].y + 1, 0.0L) * max(sk[t].x - sk[t + 1].y + 1, 0.0L); if (newVal < dp[k][n]) { dp[k][n] = newVal; } } } } return (ll)dp[K][N]; }
#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...