結果

問題 No.96 圏外です。
ユーザー koyoprokoyopro
提出日時 2015-10-02 11:37:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,132 bytes
コンパイル時間 1,416 ms
コンパイル使用メモリ 152,512 KB
実行使用メモリ 126,392 KB
最終ジャッジ日時 2023-09-27 01:24:58
合計ジャッジ時間 5,696 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
121,108 KB
testcase_01 AC 47 ms
121,308 KB
testcase_02 AC 47 ms
121,264 KB
testcase_03 WA -
testcase_04 AC 48 ms
121,488 KB
testcase_05 AC 51 ms
121,612 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 59 ms
122,016 KB
testcase_09 AC 67 ms
122,196 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 150 ms
126,392 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 118 ms
123,328 KB
testcase_23 AC 118 ms
123,356 KB
testcase_24 AC 48 ms
121,308 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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];
struct unioni { int i, j, dist2; };
vector<unioni> unions(222222);
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;
}
void updateUnion(int ui, int pi) {
    unioni u = unions[ui];
    if (u.i == -1) unions[ui].i = pi;
    else if (u.j == -1) unions[ui].j = pi;
    u = unions[ui];
    if (u.i == -1 || u.j == -1) return;
    int disti = distance2(ps[u.i], ps[pi]);
    int distj = distance2(ps[u.j], ps[pi]);
    if (disti > u.dist2 && disti > distj) {
        unions[ui].j = pi;
        unions[ui].dist2 = disti;
    } else if (distj > u.dist2 && distj > disti) {
        unions[ui].i = pi;
        unions[ui].dist2 = distj;
    }
}
signed main()
{
    cin >> N;
    int x, y;
    REP(i,unions.size()) {
        unions[i].i = -1;
        unions[i].j = -1;
    }
    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);
        updateUnion(ps[i].u, i);
    }
    for (unioni u : unions) maxl = max(maxl, sqrt(u.dist2) + 2);
    printf("%.14f\n", maxl);
    return 0;
}
0