| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1325234 | caganyanmaz | Aliens (IOI16_aliens) | C++20 | 103 ms | 1416 KiB |
#include <bits/stdc++.h>
#include "aliens.h"
using namespace std;
vector<array<int, 2>> extract_relevant_sorted_points(const vector<int>& r, const vector<int>& c);
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
assert(1 <= n && n <= 500);
assert(1 <= m && m <= 1000);
vector<array<int, 2>> pos = extract_relevant_sorted_points(r, c);
n = pos.size();
vector<vector<int>> dp(n+1, vector<int>(k+1, 1e9));
for (int j = 0; j <= k; j++) {
dp[0][j] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
for (int t = 0; t < i; t++) {
int side_length = pos[i-1][1] - pos[t][0] + 1;
int area = side_length * side_length;
int overlap_side_length = t == 0 ? 0 : max(pos[t-1][1] - pos[t][0] + 1, 0);
int overlap_area = overlap_side_length * overlap_side_length;
dp[i][j] = min(dp[i][j], dp[t][j-1] + area - overlap_area);
}
}
}
return dp[n][k];
}
vector<array<int, 2>> extract_relevant_sorted_points(const vector<int>& r, const vector<int>& c) {
const int n = r.size();
vector<array<int, 2>> sorted_points;
for (int i = 0; i < n; i++) {
sorted_points.push_back({max(r[i], c[i]), min(r[i], c[i])});
}
sort(sorted_points.begin(), sorted_points.end());
for (int i = 0; i < n; i++) {
sorted_points[i] = { sorted_points[i][1], sorted_points[i][0] };
}
vector<array<int, 2>> stack;
for (const auto [r, c] : sorted_points) {
if (!stack.empty() && stack.back()[1] == c) {
continue; // Our point is smaller
}
while (!stack.empty() && stack.back()[0] >= r) stack.pop_back();
stack.push_back({r, c});
}
return stack;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
