QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#408207 | #6517. Computational Geometry | argtarg | WA | 2ms | 3564kb | C++20 | 1.6kb | 2024-05-09 20:41:19 | 2024-05-09 20:41:20 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
#define int long long
using ll = long long;
using pii = pair<int, int>;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt = 1;
cin >> tt;
while (tt--) {
int n;
cin >> n;
vector<pii>a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
}
vector < vector < ll> >dp(n, vector < ll>(n));
auto dis = [&](pii a, pii b)->ll {
return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}; ll ma = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
dp[i][j] = dis(a[i], a[j]);
//cout << dp[i][j] << ' ';
ma = max(dp[i][j], ma);
}
//cout << endl;
}//cout << endl;
for (int i = 2; i < n; i++) {
if (0) {
for (int j = 0; j < n; j++) {
dp[j][(j + n - 1) % n] = ma;
}
continue;
}
for (int j = 0; j < n; j++) {
dp[j][(j + i) % n] = max({ dp[j][(j + i) % n] ,dp[(j + 1) % n][(j + i) % n],dp[j][(j + i - 1) % n] });
}
}
ll ans = 1e18;
auto cross = [&](pii a, pii b, pii c) ->bool {
ll x = (a.first - c.first) * (b.second - c.second) - (a.second - c.second) * (b.first - c.first);
if (x == 0)return 0;
else return 1;
};
for (int i = 2; i < n-1; i++) {
for (int j = 0; j < n; j++) {
int x = j, y = (j + i) % n;
if (i==2&&cross(a[x],a[(x+1)%n],a[y])==0||i==n-2&& cross(a[x], a[(x - 1+n) % n], a[y])==0)continue;
ans = min(ans, dp[x][y] + dp[y][x]);
//cout << x<< ' '<<y << endl;
}
}
cout << ans << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3520kb
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: 0
Accepted
time: 1ms
memory: 3564kb
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:
ok 713 numbers
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3528kb
input:
723 6 219724071 0 454078946 131628774 497404433 165947891 427997418 299842932 68283732 510015817 0 327227140 5 277969751 0 576739203 275664810 244855879 638262097 13873538 700473186 0 59956198 10 69526931 509564969 0 395765436 101436487 0 273066511 46581979 904969235 467379058 942000353 535129295 93...
output:
320990950510053393 818929519958899381 1000000000000000000 711353303900820471 683190682500395857 594439231930042527 659610359567672203 1000000000000000000 845514798756141601 410893515758460170 293647337551438590 889581785464512646 1000000000000000000 1000000000000000000 993125871111020743 88416805922...
result:
wrong answer 3rd numbers differ - expected: '1129629590903770087', found: '1000000000000000000'