結果

問題 No.96 圏外です。
ユーザー mamekinmamekin
提出日時 2015-01-17 20:09:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 3,277 bytes
コンパイル時間 2,555 ms
コンパイル使用メモリ 109,864 KB
実行使用メモリ 103,100 KB
最終ジャッジ日時 2023-09-04 20:37:14
合計ジャッジ時間 9,276 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
97,348 KB
testcase_01 AC 83 ms
97,532 KB
testcase_02 AC 82 ms
97,240 KB
testcase_03 WA -
testcase_04 AC 85 ms
97,784 KB
testcase_05 AC 87 ms
97,768 KB
testcase_06 AC 91 ms
98,000 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 105 ms
98,360 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 134 ms
99,108 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 221 ms
101,896 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 197 ms
103,100 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 83 ms
97,236 KB
testcase_25 WA -
testcase_26 AC 211 ms
101,324 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Point
{
public:
    int y, x;
    Point(){
        y = x = 0;
    }
    Point(int y0, int x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(int a) const{
        return Point(y * a, x * a);
    }
    int length2() const{
        return y * y + x * x;
    }
    int dist2(const Point& p) const{
        return (y - p.y) * (y - p.y) + (x - p.x) * (x - p.x);
    }
    int dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cosθ
    }
    int cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sinθ
    }
};

void convexHull(const vector<Point>& p0, vector<Point>& cv)
{
    class Compare{
    public:
        bool operator()(const Point& a, const Point& b){
            return a.x < b.x || (a.x == b.x && a.y < b.y);
        }
    };

    vector<Point> p = p0;
    sort(p.begin(), p.end(), Compare());
    int n = p.size();

    int j = 0;
    cv.clear();
    for(int i=0; i<2*n-1; ++i){
        Point tmp = (i<n? p[i]:p[2*(n-1)-i]);
        while(j >= 2 && (tmp-cv[j-2]).cross(cv[j-1]-cv[j-2]) < 0){
            cv.pop_back();
            -- j;
        }
        cv.push_back(tmp);
        ++ j;
    }
    cv.pop_back();
}

int main()
{
    int n;
    cin >> n;
    vector<Point> station(n);
    vector<vector<vector<int> > > grid(2003, vector<vector<int> >(2003));
    for(int i=0; i<n; ++i){
        int y, x;
        cin >> x >> y;
        y += 10010;
        x += 10010;
        station[i].y = y;
        station[i].x = x;
        grid[y/10][x/10].push_back(i);
    }

    vector<bool> check(n, false);
    double ret = 2.0;
    for(int i=0; i<n; ++i){
        if(check[i])
            continue;

        check[i] = true;
        queue<int> q;
        q.push(i);
        vector<Point> select(1, station[i]);
        while(!q.empty()){
            Point p = station[q.front()];
            q.pop();

            int y = p.y / 10;
            int x = p.x / 10;
            for(int i=0; i<9; ++i){
                for(unsigned j=0; j<grid[y+i/3-1][x+i%3-1].size(); ++i){
                    int k = grid[y+i/3-1][x+i%3-1][j];
                    if(!check[k] && p.dist2(station[k]) <= 100){
                        check[k] = true;
                        q.push(k);
                        select.push_back(station[k]);
                    }
                }
            }
        }

        vector<Point> cv;
        convexHull(select, cv);

        int m = cv.size();
        int j = 0;
        for(int i=0; i<m; ++i){
            while(cv[i].dist2(cv[j]) < cv[i].dist2(cv[(j+1)%m]))
                j = (j + 1) % m;
            ret = max(ret, sqrt((double)cv[i].dist2(cv[j])) + 2.0);
        }
    }
    printf("%.10f\n", ret);

    return 0;
}
0