QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#386320 | #5809. Min Perimeter | 0x3b800001 | 0 | 19996ms | 340104kb | C++14 | 1.6kb | 2024-04-11 15:30:37 | 2024-04-11 15:30:38 |
Judging History
answer
#include <algorithm>
#include <chrono>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <random>
using ld = double;
int n;
using Point = std::complex<ld>;
Point P[1000007];
ld diss[1000007][41];
const ld pi = acosl(-1);
inline ld dis(Point& lhs, Point& rhs) { return std::abs(lhs - rhs); }
inline ld T(Point& A, Point& B, Point& C) { return dis(A, B) + dis(B, C) + dis(C, A); }
void solve() {
std::cin >> n;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
Point r = std::exp(Point(0, std::uniform_real_distribution<>(-pi, pi)(rng)));
Point rr = std::exp(Point(3, std::uniform_real_distribution<>(-pi, pi)(rng)));
for (int i = 1; i <= n; ++i) {
ld x, y;
std::cin >> x >> y;
P[i] = Point(x, y) * r + rr;
}
std::sort(P + 1, P + n + 1, [](Point lhs, Point rhs) {
return lhs.real() * lhs.imag() < rhs.real() * rhs.imag();
});
for (int i = 1; i <= n; ++i) {
for (int j = i + 1; j <= n && j <= i + 40; ++j) {
diss[i][j - i] = dis(P[i], P[j]);
}
}
ld ans = 1e18;
for (int i = 1; i <= n - 2; ++i) {
for (int j = i + 1; j <= n && j <= i + 40; ++j) {
for (int k = j + 1; k <= n && k <= i + 40; ++k) {
ans = std::min(ans, diss[i][j - i] + diss[j][k - j] + diss[i][k - i]);
}
}
}
std::cout << std::fixed << std::setprecision(14) << ans << '\n';
}
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int t;
std::cin >> t;
for (int i = 1; i <= t; ++i) {
std::cout << "Case #" << t << ": ";
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 187ms
memory: 10684kb
input:
15 3 2 6 7 0 3 0 3 713 269 371 79 455 421 3 91983245 637281504 756917015 312173515 869576338 436726680 10000 14761642 78236002 9047458 47951098 5238002 27761162 476182 2523742 1428546 7571226 26190010 138805810 21904372 116092132 18094916 95902196 43332562 229660522 55237112 292754072 52380020 27761...
output:
Case #15: 17.89301220620488 Case #15: 1042.84483496438838 Case #15: 1711142102.79132723808289 Case #15: 90912.29637388611445 Case #15: 3.41421356237305 Case #15: 26.15383034216383 Case #15: 1701.01268109561670 Case #15: 2865438.19199382606894 Case #15: 2020088.33722622040659 Case #15: 1792106.037291...
result:
wrong output format Expected '#1:' but found '#15:' (test case 1)
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 19996ms
memory: 340104kb
input:
15 3 501691275 344354353 167768963 536043860 249445040 557426549 4 1000000000 0 0 0 1000000000 1000000000 0 1000000000 1000000 138925776 669369648 61257680 295150640 170762328 822763944 55483472 267329456 97736936 470914328 84041848 404928904 18463588 88960924 124429360 599523280 95066048 458045504 ...
output:
Case #15: 799653579.13308966159821 Case #15: 3414213562.37309455871582 Case #15: 866.07159028377987 Case #15: 62459.89536978489923 Case #15: 59141.91835914671537 Case #15: 898200.35246481839567 Case #15: 1707101.20907216705382 Case #15: 1703.58309032474881 Case #15: 1702.08048770474829 Case #15: 680...
result:
wrong output format Expected '#1:' but found '#15:' (test case 1)