結果

問題 No.96 圏外です。
ユーザー mamekin
提出日時 2015-01-17 20:29:52
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 280 ms / 5,000 ms
コード長 3,332 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 114,132 KB
実行使用メモリ 103,116 KB
最終ジャッジ日時 2024-12-24 08:05:35
合計ジャッジ時間 7,460 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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();
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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0