結果

問題 No.96 圏外です。
ユーザー koyoprokoyopro
提出日時 2015-10-02 11:32:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,111 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 150,824 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 01:24:42
合計ジャッジ時間 7,775 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

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

int N;
struct pos {  int x, y, u; pos(int _x, int _y): x(_x), y(_y){}; };
vector<pos> ps;
vector<pos> area[AREAS][AREAS];
struct unioni { int i, j, dist2; };
vector<unioni> unions(22);//2222);
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 (pos p1 : area[nx][ny]) {
                if (distance2(p, p1) <= 100) {
                    uni(p, p1);
                    found = true;
                    break;
                }
            }
            if (found) break;
        }
        area[ap.x][ap.y].push_back(ps[i]);
        updateUnion(ps[i].u, i);
    }
    for (unioni u : unions) maxl = max(maxl, sqrt(u.dist2) + 2);
    printf("%.14f\n", maxl);
    return 0;
}
0