QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386035#5809. Min Perimetercyb10100 2363ms19884kbC++142.3kb2024-04-11 11:17:152024-04-11 11:17:16

Judging History

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

  • [2024-04-11 11:17:16]
  • 评测
  • 测评结果:0
  • 用时:2363ms
  • 内存:19884kb
  • [2024-04-11 11:17:15]
  • 提交

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];
db ans = 1e12;
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();
        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: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 6344kb

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: 17.89301220620487
Case #3: 17.89301220620487
Case #4: 17.89301220620487
Case #5: 3.41421356237309
Case #6: 3.41421356237309
Case #7: 3.41421356237309
Case #8: 3.41421356237309
Case #9: 3.41421356237309
Case #10: 3.41421356237309
Case #11: 3.41421356237309
Case #12...

result:

wrong answer read 17.893012206205 but expected 1042.844834964388 (test case 2)

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 2363ms
memory: 19884kb

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: 799653579.13308978080750
Case #3: 866.07159057435888
Case #4: 866.07159057435888
Case #5: 866.07159057435888
Case #6: 866.07159057435888
Case #7: 866.07159057435888
Case #8: 866.07159057435888
Case #9: 866.07159057435888
Case #10: 866.07159057435888
Case #1...

result:

wrong answer read 799653579.133089780807 but expected 3414213562.373095035553 (test case 2)