Submission #773704

#TimeUsernameProblemLanguageResultExecution timeMemory
773704JomnoiAliens (IOI16_aliens)C++17
12 / 100
128 ms4148 KiB
#include <bits/stdc++.h> #include "aliens.h" using namespace std; const int MAX_K = 1005; const int MAX_N = 1005; const long long INF = 1e18 + 7; int N, M, K; int X[MAX_N], Y[MAX_N], id[MAX_N]; long long dp[MAX_K][MAX_N]; int qs[MAX_N][MAX_N]; bool dead[MAX_N]; long long take_photos(int n, int m, int k, vector <int> r, vector <int> c) { N = n, M = m, K = k; for (int i = 0; i < N; i++) { X[i] = min(r[i], c[i]), Y[i] = max(r[i], c[i]); id[i] = i; } for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (X[i] <= X[j] and Y[j] <= Y[i]) dead[j] = true; else if (X[j] <= X[i] and Y[i] <= Y[j]) dead[i] = true; } } N = 0; for (int i = 0; i < n; i++) { if (dead[i] == false) { X[N] = X[i], Y[N] = Y[i]; N++; } } sort(id, id + N, [&](const int &a, const int &b) { return Y[a] < Y[b]; }); for (int i = 1; i <= N; i++) dp[0][i] = INF; for (int k = 1; k <= K; k++) { for (int i = 1; i <= N; i++) { dp[k][i] = INF; int minL = M; for (int j = i; j >= 1; j--) { minL = min(minL, X[id[j - 1]]); // cout << minL << ' ' << Y[id[i - 1]] << endl; long long cost = (Y[id[i - 1]] - minL + 1) * (Y[id[i - 1]] - minL + 1); dp[k][i] = min(dp[k][i], cost + dp[k - 1][j - 1]); } // cout << k << ' ' << i << " : " << dp[k][i] << endl; } } long long ans = INF; for (int k = 1; k <= K; k++) ans = min(ans, dp[k][N]); 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...