結果

問題 No.96 圏外です。
ユーザー kimiyukikimiyuki
提出日時 2017-01-07 00:15:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,573 bytes
コンパイル時間 1,107 ms
コンパイル使用メモリ 91,504 KB
実行使用メモリ 31,084 KB
最終ジャッジ日時 2023-08-25 22:14:53
合計ジャッジ時間 18,804 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
26,484 KB
testcase_01 AC 22 ms
26,504 KB
testcase_02 AC 21 ms
26,480 KB
testcase_03 AC 22 ms
26,792 KB
testcase_04 AC 24 ms
27,088 KB
testcase_05 AC 26 ms
27,224 KB
testcase_06 AC 28 ms
27,408 KB
testcase_07 AC 31 ms
27,340 KB
testcase_08 AC 35 ms
27,528 KB
testcase_09 AC 40 ms
27,940 KB
testcase_10 AC 53 ms
27,972 KB
testcase_11 AC 56 ms
27,948 KB
testcase_12 AC 69 ms
28,420 KB
testcase_13 AC 112 ms
27,992 KB
testcase_14 AC 100 ms
28,940 KB
testcase_15 AC 392 ms
28,364 KB
testcase_16 AC 149 ms
29,432 KB
testcase_17 AC 149 ms
31,084 KB
testcase_18 AC 186 ms
29,960 KB
testcase_19 AC 189 ms
29,912 KB
testcase_20 AC 3,454 ms
29,456 KB
testcase_21 AC 3,835 ms
29,672 KB
testcase_22 AC 3,633 ms
28,836 KB
testcase_23 AC 3,392 ms
28,876 KB
testcase_24 AC 22 ms
26,496 KB
testcase_25 AC 113 ms
29,824 KB
testcase_26 AC 144 ms
30,616 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
                            }
                        }
                    }
                }
            }
        }
        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