結果

問題 No.96 圏外です。
ユーザー koyoprokoyopro
提出日時 2015-10-02 12:03:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,808 bytes
コンパイル時間 1,234 ms
コンパイル使用メモリ 153,092 KB
実行使用メモリ 131,612 KB
最終ジャッジ日時 2023-09-27 01:27:34
合計ジャッジ時間 15,505 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
119,164 KB
testcase_01 AC 46 ms
119,184 KB
testcase_02 AC 46 ms
119,328 KB
testcase_03 AC 46 ms
119,308 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define AREAS 2222
#define DIFF 1e4
#define int long long

int N;
struct pos {  int x, y, u; pos(int _x, int _y): x(_x), y(_y){}; };
vector<pos> ps;
vector<int> area[AREAS][AREAS];
pos areapos(pos p) {
    return pos(p.x / 10, p.y / 10);
}
int distance2(pos a, pos b) {
    return pow(a.x - b.x, 2) + pow(a.y - b.y, 2);
}
int root(int i) {
    if (ps[i].u == i) return i;
    return ps[i].u = root(ps[i].u);
}
void uni(pos p1, pos p2) {
    ps[root(p1.u)].u = ps[root(p2.u)].u;
}
signed main()
{
    cin >> N;
    int x, y;
    double maxl = (N > 0) ? 2.0 : 1.0;
    REP(i,N) {
        cin>>x>>y;
        pos p = pos(x+DIFF, y+DIFF);
        p.u = i;
        ps.push_back(p);

        int dxy9[] = {0, 1, -1};
        pos ap = areapos(p);
        int found = false;
        REP(i,9) {
            int nx = ap.x + dxy9[i/3];
            int ny = ap.y + dxy9[i%3];
            if (nx<0||2000<=nx||ny<0||2000<=ny) continue;
            for (int pi : area[nx][ny]) {
                pos p1 = ps[pi];
                if (distance2(p, p1) <= 100) {
                    uni(p, p1);
                    found = true;
                    break;
                }
            }
            if (found) break;
        }
        area[ap.x][ap.y].push_back(i);
    }
    vector< vector<int> > unis(N);
    REP(i,N) {
        unis[root(i)].push_back(i);
    }
    REP(i,N) {
        if (unis[i].size() < 2) continue;
        int maxd = 0;
        REP(j,unis[i].size()) {
            FOR(k,j+1,unis[i].size()) {
                maxd = max(maxd, distance2(ps[k], ps[j]));
            }
        }
        maxl = max(maxl, sqrt(maxd) + 2);
    }
    printf("%.14f\n", maxl);
    return 0;
}
0