結果

問題 No.96 圏外です。
ユーザー kimiyukikimiyuki
提出日時 2017-01-07 00:12:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,664 bytes
コンパイル時間 1,138 ms
コンパイル使用メモリ 108,392 KB
実行使用メモリ 31,488 KB
最終ジャッジ日時 2024-05-09 21:21:25
合計ジャッジ時間 6,896 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
27,008 KB
testcase_01 AC 23 ms
27,136 KB
testcase_02 AC 23 ms
27,008 KB
testcase_03 AC 23 ms
27,136 KB
testcase_04 AC 26 ms
27,264 KB
testcase_05 AC 28 ms
27,264 KB
testcase_06 AC 33 ms
27,520 KB
testcase_07 AC 37 ms
27,520 KB
testcase_08 AC 43 ms
27,904 KB
testcase_09 AC 52 ms
27,904 KB
testcase_10 AC 68 ms
28,160 KB
testcase_11 AC 82 ms
28,128 KB
testcase_12 AC 97 ms
28,800 KB
testcase_13 AC 138 ms
28,416 KB
testcase_14 AC 142 ms
29,312 KB
testcase_15 AC 210 ms
28,928 KB
testcase_16 AC 217 ms
29,952 KB
testcase_17 AC 218 ms
31,488 KB
testcase_18 AC 269 ms
30,336 KB
testcase_19 AC 285 ms
30,336 KB
testcase_20 WA -
testcase_21 AC 205 ms
29,824 KB
testcase_22 AC 509 ms
28,928 KB
testcase_23 AC 522 ms
28,928 KB
testcase_24 AC 23 ms
27,008 KB
testcase_25 AC 155 ms
30,208 KB
testcase_26 AC 206 ms
30,848 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <random>
#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() {
    random_device device;
    default_random_engine engine(device());
    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;
                            }
                        }
                    }
                }
            }
        }
        repeat (iteration,10) {
            int j = uniform_int_distribution<int>(0, acc.size()-1)(engine);
            j = farthest(j, acc);
            int k = farthest(j, acc);
            setmax(ans, dist(j, k) + 2);
        }
    }
    printf("%.9lf\n", ans);
    return 0;
}
0