結果

問題 No.96 圏外です。
ユーザー kimiyukikimiyuki
提出日時 2017-02-06 17:40:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,816 bytes
コンパイル時間 936 ms
コンパイル使用メモリ 92,204 KB
実行使用メモリ 31,096 KB
最終ジャッジ日時 2023-08-25 23:03:23
合計ジャッジ時間 18,951 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
26,604 KB
testcase_01 WA -
testcase_02 AC 22 ms
26,456 KB
testcase_03 AC 22 ms
26,448 KB
testcase_04 AC 25 ms
27,256 KB
testcase_05 AC 26 ms
27,380 KB
testcase_06 AC 29 ms
27,340 KB
testcase_07 AC 32 ms
27,328 KB
testcase_08 AC 36 ms
27,520 KB
testcase_09 AC 41 ms
27,900 KB
testcase_10 AC 51 ms
27,748 KB
testcase_11 AC 56 ms
28,096 KB
testcase_12 AC 70 ms
28,380 KB
testcase_13 AC 93 ms
27,996 KB
testcase_14 AC 96 ms
28,716 KB
testcase_15 AC 275 ms
28,516 KB
testcase_16 AC 139 ms
29,596 KB
testcase_17 AC 156 ms
31,096 KB
testcase_18 AC 180 ms
30,092 KB
testcase_19 AC 172 ms
30,036 KB
testcase_20 AC 3,531 ms
29,304 KB
testcase_21 AC 3,960 ms
29,668 KB
testcase_22 AC 3,675 ms
28,696 KB
testcase_23 AC 3,428 ms
28,864 KB
testcase_24 WA -
testcase_25 AC 110 ms
29,616 KB
testcase_26 AC 143 ms
30,480 KB
testcase_27 AC 126 ms
29,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
bool is_on_field(int y, int x, int h, int w) { return 0 <= y and y < h and 0 <= x and x < w; }
int main() {
    int n; cin >> n;
    vector<int> x(n), y(n);
    repeat (i,n) {
        cin >> x[i] >> y[i];
        x[i] += 10000;
        y[i] += 10000;
        assert (0 <= y[i] and y[i] <= 20000);
        assert (0 <= x[i] and x[i] <= 20000);
    }
    function<double (int, int)> dist = [&](int i, int j) { return hypot(x[i] - x[j], y[i] - y[j]); };
    function<int (int, vector<int> const &)> farthest = [&](int i, vector<int> const & acc) {
        return *whole(max_element, acc, [&](int j, int k) { return dist(i, j) < dist(i, k); });
    };
    const int Q = 20;
    const int K = 20000 / Q + 1;
    assert (20000 / Q < K);
    auto bucket = vectors(K, K, vector<int>());
    repeat (i,n) bucket[y[i] / Q][x[i] / Q].push_back(i);
    double ans = 1;
    vector<bool> used(n);
    repeat (i,n) if (not used[i]) {
        vector<int> acc; {
            int it = 0;
            acc.push_back(i);
            used[i] = true;
            while (it < acc.size()) {
                int j = acc[it]; ++ it;
                for (int dy : { -1, 0, 1 }) {
                    for (int dx : { -1, 0, 1 }) {
                        int ny = y[j] / Q + dy;
                        int nx = x[j] / Q + dx;
                        if (is_on_field(ny, nx, K, K)) {
                            for (int k : bucket[ny][nx]) if (not used[k] and dist(j, k) <= 10) {
                                acc.push_back(k);
                                used[k] = true;
                            }
                        }
                    }
                }
            }
        }
        if (acc.size() < 300) {
            repeat (j, acc.size()) {
                repeat (i, j) {
                    setmax(ans, dist(acc[i], acc[j]) + 2);
                }
            }
        } else {
            whole(random_shuffle, acc);
            repeat (i, min<int>(300, acc.size())) {
                int j = farthest(i, acc);
                int k = farthest(j, acc);
                setmax(ans, dist(j, k) + 2);
            }
        }
    }
    printf("%.9lf\n", ans);
    return 0;
}
0