QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#116678 | #6517. Computational Geometry | ITMO_pengzoo# | WA | 2ms | 3484kb | C++20 | 1.7kb | 2023-06-29 19:24:11 | 2023-06-29 19:24:14 |
Judging History
answer
// Nikita Golikov, 2023
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#ifdef GOLIKOV
#include "/Users/golikovnik/contests/debug.h"
#else
#define debug(...) ;
#endif
template <class A, class B>
bool smin(A& x, B&& y) {
if (y < x) {
x = y;
return true;
}
return false;
}
template <class A, class B>
bool smax(A& x, B&& y) {
if (x < y) {
x = y;
return true;
}
return false;
}
void solveTest() {
int n; cin >> n;
vector<pair<int, int>> a(n);
for (auto& [x, y] : a) {
cin >> x >> y;
}
auto sqr = [&](ll x) {
return x * x;
};
auto Dist = [&](int i, int j) {
return sqr(a[i].first - a[j].first) + sqr(a[i].second - a[j].second);
};
vector dp(2 * n, vector<ll>(2 * n));
for (int r = 0; r < 2 * n; ++r) {
for (int l = r - 1; l >= 0; --l) {
dp[l][r] = max({dp[l + 1][r], dp[l][r - 1], Dist(l % n, r % n)});
debug(l, r, dp[l][r]);
}
}
ll ans = LLONG_MAX;
for (int s = 0; s < n; ++s) {
for (int cnt = 3; n - cnt + 2 >= 3; ++cnt) {
smin(ans, dp[s][s + cnt - 1] + dp[s + cnt - 1][s + n]);
}
}
cout << ans << '\n';
}
int main() {
#ifdef GOLIKOV
assert(freopen("in", "rt", stdin));
auto _clock_start = chrono::high_resolution_clock::now();
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tests_;
cin >> tests_;
for (int tt_ = 1; tt_ <= tests_; ++tt_) {
solveTest();
}
#ifdef GOLIKOV
cerr << "Executed in " << chrono::duration_cast<chrono::milliseconds>(
chrono::high_resolution_clock::now()
- _clock_start).count() << "ms." << endl;
#endif
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3460kb
input:
2 4 1 0 2 0 1 1 0 0 6 10 4 9 7 5 7 4 5 6 4 9 3
output:
4 44
result:
ok 2 number(s): "4 44"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3484kb
input:
713 8 8 25 3 15 0 5 10 0 19 2 24 6 23 15 15 34 8 25 16 18 25 10 32 1 23 0 14 21 0 27 2 32 6 7 16 15 8 20 1 16 0 12 16 0 21 1 24 5 7 15 1 18 0 24 8 27 15 4 19 0 17 7 8 4 10 20 0 30 15 0 14 10 6 15 0 24 10 21 14 12 14 7 11 0 3 7 18 7 16 9 12 10 6 9 0 4 5 0 15 1 9 0 23 8 13 14 6 24 0 34 1 41 11 37 20 1...
output:
1075 1389 706 687 1550 497 300 1668 471 162 519 190 786 983 367 930 580 524 509 275 617 298 146 1330 494 965 599 1321 866 1210 233 398 560 1548 871 938 366 500 371 1118 1222 1994 712 586 858 624 697 575 1274 882 1035 406 934 670 990 1231 513 2871 939 2735 1610 834 721 585 203 198 1666 617 1166 326 2...
result:
wrong answer 120th numbers differ - expected: '294', found: '284'