| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 94585 | wxh010910 | Aliens (IOI16_aliens) | C++17 | 114 ms | 6364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "aliens.h"
using namespace std;
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
vector<pair<int, int>> p(n);
for (int i = 0; i < n; ++i) {
p[i].first = min(r[i], c[i]);
p[i].second = max(r[i], c[i]);
}
sort(p.begin(), p.end());
{
vector<pair<int, int>> new_p;
for (int i = 0, j = 0; i < n; i = j) {
while (j < n && p[j].first == p[i].first) {
++j;
}
if (new_p.empty() || p[j - 1].second > new_p.back().second) {
new_p.push_back(p[j - 1]);
}
}
swap(p, new_p);
n = p.size();
}
k = min(k, n);
vector<int> x(n), y(n);
for (int i = 0; i < n; ++i) {
x[i] = p[i].first;
y[i] = p[i].second;
}
vector<long long> f(n + 1);
vector<int> g(n + 1);
auto sqr = [&](int x) {
return (long long) x * x;
};
auto solve = [&](long long c) {
vector<int> q(n + 1);
int l = 0, r = 0;
auto check = [&](int a, int b, int c) {
return (f[a] + sqr(x[a]) - f[c] - sqr(x[c])) * (x[b] - x[c]) < (f[b] + sqr(x[b]) - f[c] - sqr(x[c])) * (x[a] - x[c]);
};
for (int i = 0; i < n; ++i) {
while (r - l > 1 && check(i, q[r - 1], q[r - 2])) {
--r;
}
q[r++] = i;
while (r - l > 1 && f[q[l]] + sqr(y[i] - x[q[l]] + 1) > f[q[l + 1]] + sqr(y[i] - x[q[l + 1]] + 1)) {
++l;
}
f[i + 1] = f[q[l]] + sqr(y[i] - x[q[l]] + 1) + c;
if (i + 1 < n && y[i] >= x[i + 1]) {
f[i + 1] -= sqr(y[i] - x[i + 1] + 1);
}
g[i + 1] = g[q[l]] + 1;
}
};
long long low = 0, high = 1ll << 40;
while (low < high) {
long long mid = low + high >> 1;
solve(mid);
if (g[n] <= k) {
high = mid;
} else {
low = mid + 1;
}
}
solve(high);
return f[n] - k * high;
}
컴파일 시 표준 에러 (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... | ||||
