QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386036#5809. Min Perimetercyb101020 ✓4883ms19892kbC++142.3kb2024-04-11 11:17:392024-04-11 11:17:40

Judging History

你现在查看的是最新测评结果

  • [2024-04-11 11:17:40]
  • 评测
  • 测评结果:20
  • 用时:4883ms
  • 内存:19892kb
  • [2024-04-11 11:17:39]
  • 提交

answer

/**
 * @author : cyb1010
 * @date   : 2024-04-11 08:17:09
 * @file   : triangle.cpp
 */
#include <bits/stdc++.h>
using namespace std;
namespace FastIO {
const std::size_t buf_size = 1 << 18;
char I[buf_size], *p1, *p2, O[buf_size], s[128];
int p, q, f;
inline char gc() {
    return p1 == p2 && (p2 = (p1 = I) + fread(I, 1, sizeof(I), stdin), p1 == p2)
               ? EOF
               : *p1++;
}
inline void pc(char c) { O[p++] = c; }
inline void flush() { fwrite(O, 1, p, stdout), p = 0; }
void chkf() {
    if (p >= buf_size >> 1) flush();
}
struct AutoFlush {
    ~AutoFlush() { flush(); }
} auto_flush;

template <typename T>
void rd(T &x) {
    char c = gc();
    x = 0, f = c == '-';
    while (!isdigit(c)) c = gc(), c == '-' ? f = 1 : 0;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc();
    f ? x = -x : 1;
}
template <typename T>
void wr(T x) {
    if (x < 0) x = -x, pc('-');
    do s[++q] = (x % 10) | 48;
    while (x /= 10);
    do pc(s[q]);
    while (--q);
    chkf();
}
template <typename T>
void wr(T x, char c) {
    wr(x), pc(c);
}
} // namespace FastIO
using FastIO::rd;
using FastIO::wr;
#define fo(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
#define fi first
#define se second
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<db, db> pii;
const int N = 1000010;
int __, n, _;
pii a[N];
multiset<pii> S;
db sq(db x) { return x * x; }
db dis(pii x, pii y) { return sqrt(sq(x.fi - y.fi) + sq(x.se - y.se)); }
int main() {
    rd(_);
    for (int I = 1; I <= _; I++) {
        rd(n), S.clear();
        db ans = 1e12;
        for (int i = 1; i <= n; i++) rd(a[i].fi), rd(a[i].se);
        sort(a + 1, a + 1 + n);
        for (int i = 1; i <= n; i++) swap(a[i].fi, a[i].se);
        for (int i = 1, L = 1; i <= n; i++) {
            while (a[L].se + ans / 2 <= a[i].se) S.erase(S.find(a[L++]));
            auto x = S.upper_bound({a[i].fi - ans / 2, 0}),
                 y = S.upper_bound({a[i].fi + ans / 2, 0});
            for (auto p = x; p != y; p = next(p))
                for (auto q = x; q != p; q = next(q))
                    ans = min(ans, dis(*p, a[i]) + dis(*q, a[i]) + dis(*p, *q));
            S.insert(a[i]);
        }
        printf("Case #%d: %.14lf\n", I, ans);
    }
    return 0 ^ __ ^ 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 26ms
memory: 4300kb

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 #1: 17.89301220620487
Case #2: 1042.84483496438816
Case #3: 1711142102.79132699966431
Case #4: 90912.29637403292872
Case #5: 3.41421356237309
Case #6: 26.15383034216369
Case #7: 1701.01268109561670
Case #8: 2865438.19199387123808
Case #9: 2020088.33722631982528
Case #10: 1792106.03729207115248
...

result:

ok correct! (15 test cases)

Subtask #2:

score: 15
Accepted

Test #2:

score: 15
Accepted
time: 4883ms
memory: 19892kb

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 #1: 799653579.13308978080750
Case #2: 3414213562.37309503555298
Case #3: 866.07159057435888
Case #4: 62459.89536963714636
Case #5: 59141.91835893178359
Case #6: 898195.09096826799214
Case #7: 1707085.76998678524978
Case #8: 1686.22679825813566
Case #9: 1686.60354597163496
Case #10: 6806.6655839...

result:

ok correct! (15 test cases)

Extra Test:

score: 0
Extra Test Passed