結果
問題 | No.96 圏外です。 |
ユーザー | mamekin |
提出日時 | 2015-01-17 20:29:52 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 223 ms / 5,000 ms |
コード長 | 3,332 bytes |
コンパイル時間 | 1,273 ms |
コンパイル使用メモリ | 110,116 KB |
実行使用メモリ | 103,292 KB |
最終ジャッジ日時 | 2023-08-25 21:36:22 |
合計ジャッジ時間 | 7,005 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
97,296 KB |
testcase_01 | AC | 80 ms
97,192 KB |
testcase_02 | AC | 80 ms
97,348 KB |
testcase_03 | AC | 78 ms
97,252 KB |
testcase_04 | AC | 82 ms
97,636 KB |
testcase_05 | AC | 86 ms
97,692 KB |
testcase_06 | AC | 87 ms
97,804 KB |
testcase_07 | AC | 87 ms
98,044 KB |
testcase_08 | AC | 93 ms
98,288 KB |
testcase_09 | AC | 100 ms
98,372 KB |
testcase_10 | AC | 102 ms
98,476 KB |
testcase_11 | AC | 117 ms
98,708 KB |
testcase_12 | AC | 133 ms
99,084 KB |
testcase_13 | AC | 137 ms
99,132 KB |
testcase_14 | AC | 156 ms
99,720 KB |
testcase_15 | AC | 165 ms
99,736 KB |
testcase_16 | AC | 191 ms
100,672 KB |
testcase_17 | AC | 221 ms
101,904 KB |
testcase_18 | AC | 220 ms
101,476 KB |
testcase_19 | AC | 223 ms
101,416 KB |
testcase_20 | AC | 190 ms
100,136 KB |
testcase_21 | AC | 186 ms
103,292 KB |
testcase_22 | AC | 222 ms
101,140 KB |
testcase_23 | AC | 215 ms
101,248 KB |
testcase_24 | AC | 80 ms
97,248 KB |
testcase_25 | AC | 178 ms
100,528 KB |
testcase_26 | AC | 208 ms
101,200 KB |
testcase_27 | AC | 183 ms
100,684 KB |
ソースコード
#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(); if(n == 1){ cv = p0; return; } 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 = 1.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(); ++j){ 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; }