QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#304689 | #6517. Computational Geometry | ucup-team2894# | WA | 2ms | 3892kb | C++17 | 2.3kb | 2024-01-14 00:07:55 | 2024-01-14 00:07:55 |
Judging History
answer
#include <bits/stdc++.h>
#define fr first
#define sc second
#define all(a) (a).begin(), (a).end()
#define unique(a) a.resize(unique(a.begin(), a.end()) - a.begin())
using namespace std;
#ifdef ONPC
mt19937 rnd(223);
#else
mt19937 rnd(chrono::high_resolution_clock::now()
.time_since_epoch().count());
#endif
#define TIME (clock() * 1.0 / CLOCKS_PER_SEC)
using ll = long long;
using ld = double;
const int maxn = 1e4 + 100, inf = 1e9 + 100;
ll dp[maxn][maxn];
#define cin if(1)cin
void solve() {
int n;
n = 5e3;
cin >> n;
vector<pair<int, int>> a(2 * n);
auto cross = [&](pair<int, int> x, pair<int, int> y) -> ll {
return x.fr * (ll)y.sc - x.sc * (ll)y.fr;
};
for (int i = 0; i < n; i++) {
a[i].fr = rnd() % 100000 + 1;
a[i].sc = rnd() % 100000 + 1;
cin >> a[i].fr >> a[i].sc;
}
for (int i = n; i < 2 * n; i++)
a[i] = a[i - n];
for (int i = 0; i < 2 * n; i++)
fill(dp[i], dp[i] + 2 * n, 0);
for (int i = 0; i < 2 * n; i++)
for (int j = i + 1; j < 2 * n; j++)
dp[i][j] = (a[i].fr - a[j].fr) * (a[i].fr - a[j].fr) + (a[i].sc - a[j].sc) * (a[i].sc - a[j].sc);
for (int len = 1; len < 2 * n; len++)
for (int l = 0; l + len < 2 * n; l++) {
int r = l + len;
dp[l][r] = max({dp[l][r], dp[l + 1][r], dp[l][r - 1]});
}
vector<int> last(2 * n);
for (int i = 0; i < 2 * n; i++) {
ll s = 0;
last[i] = i;
for (int j = i + 1; j < 2 * n; j++) {
s += cross(a[j - 1], a[j]);
if (s + cross(a[j], a[i]) == 0)
last[i]++;
else
break;
}
}
ll ans = numeric_limits<ll>::max();
for (int l = 0; l < n; l++)
for (int r = l + 1; r < n; r++) {
ll x = dp[l][r], y = dp[r][l + n];
if (last[l] < r && last[r] < l + n)
ans = min(ans, x + y);
}
cout << ans << '\n';
}
int main() {
#ifdef ONPC
freopen("../a.in", "r", stdin);
// freopen("../a.out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed;
cout.precision(20);
int ts;
ts = 1;
cin >> ts;
while (ts--)
solve();
cerr << "\n\nConsumed " << TIME << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
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: 2ms
memory: 3868kb
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: 3892kb
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:
1046951754 2522686765 2316461940 2026725188 2035725221 2113424197 2028418881 1875595986 2806958665 1415109229 1375888229 1818757381 1874102161 1919327594 1918337498 2892674615 2126009928 1289621834 1929267560 2147428953 1910267099 1970599034 2134505925 1828728516 1767097258 402934916 2328506781 2251...
result:
wrong answer 1st numbers differ - expected: '320990950510053393', found: '1046951754'