結果
| 問題 |
No.96 圏外です。
|
| コンテスト | |
| ユーザー |
anta
|
| 提出日時 | 2014-12-07 20:33:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 7,264 bytes |
| コンパイル時間 | 1,204 ms |
| コンパイル使用メモリ | 107,560 KB |
| 実行使用メモリ | 60,516 KB |
| 最終ジャッジ日時 | 2024-06-11 16:31:59 |
| 合計ジャッジ時間 | 7,895 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 1 -- * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:123:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
123 | scanf("%d%d", &X[i], &Y[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
const int C = 317;
const int circle[C] = {-200210,-180193,-180192,-180191,-180190,-180189,-180188,-180187,-180186,-180185,-160174,-160173,-160172,-160171,-160170,-160169,-160168,-160167,-160166,-160165,-160164,-160163,-160162,-140154,-140153,-140152,-140151,-140150,-140149,-140148,-140147,-140146,-140145,-140144,-140143,-140142,-140141,-140140,-120134,-120133,-120132,-120131,-120130,-120129,-120128,-120127,-120126,-120125,-120124,-120123,-120122,-120121,-120120,-120119,-120118,-100113,-100112,-100111,-100110,-100109,-100108,-100107,-100106,-100105,-100104,-100103,-100102,-100101,-100100,-100099,-100098,-100097,-80093,-80092,-80091,-80090,-80089,-80088,-80087,-80086,-80085,-80084,-80083,-80082,-80081,-80080,-80079,-80078,-80077,-80076,-80075,-60072,-60071,-60070,-60069,-60068,-60067,-60066,-60065,-60064,-60063,-60062,-60061,-60060,-60059,-60058,-60057,-60056,-60055,-60054,-40051,-40050,-40049,-40048,-40047,-40046,-40045,-40044,-40043,-40042,-40041,-40040,-40039,-40038,-40037,-40036,-40035,-40034,-40033,-20030,-20029,-20028,-20027,-20026,-20025,-20024,-20023,-20022,-20021,-20020,-20019,-20018,-20017,-20016,-20015,-20014,-20013,-20012,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,20012,20013,20014,20015,20016,20017,20018,20019,20020,20021,20022,20023,20024,20025,20026,20027,20028,20029,20030,40033,40034,40035,40036,40037,40038,40039,40040,40041,40042,40043,40044,40045,40046,40047,40048,40049,40050,40051,60054,60055,60056,60057,60058,60059,60060,60061,60062,60063,60064,60065,60066,60067,60068,60069,60070,60071,60072,80075,80076,80077,80078,80079,80080,80081,80082,80083,80084,80085,80086,80087,80088,80089,80090,80091,80092,80093,100097,100098,100099,100100,100101,100102,100103,100104,100105,100106,100107,100108,100109,100110,100111,100112,100113,120118,120119,120120,120121,120122,120123,120124,120125,120126,120127,120128,120129,120130,120131,120132,120133,120134,140140,140141,140142,140143,140144,140145,140146,140147,140148,140149,140150,140151,140152,140153,140154,160162,160163,160164,160165,160166,160167,160168,160169,160170,160171,160172,160173,160174,180185,180186,180187,180188,180189,180190,180191,180192,180193,200210};
int sq(int x) { return x*x; }
int pack(int y, int x) {
return (y + 10011) * 20021 + (x + 10011);
}
struct P {
typedef int T; typedef ll T2; //T2は{a*b | a:T, b:T}を含むタイプ
T x, y;
P(T x_, T y_): x(x_), y(y_) {}
P(): x(0), y(0) {}
};
inline bool operator==(const P& a, const P& b) { return a.x == b.x && a.y == b.y; }
inline bool operator<(const P& a, const P& b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }
inline P operator+(const P& a, const P& b) { return P(a.x+b.x, a.y+b.y); }
inline P operator-(const P& a, const P& b) { return P(a.x-b.x, a.y-b.y); }
inline P operator-=(P& a, const P& b) { a.x -= b.x, a.y -= b.y ; return a; }
inline P::T2 cross(const P& a, const P& b) { return (P::T2)a.x*b.y - (P::T2)a.y*b.x; }
inline P::T2 dot(const P& a, const P& b) { return (P::T2)a.x*b.x + (P::T2)a.y*b.y; }
inline P::T2 norm(const P& a) { return (P::T2)a.x*a.x + (P::T2)a.y*a.y; }
ostream& operator<<(ostream& out, const P& x) { out << "(" << x.x << ", " << x.y << ")"; return out; }
struct L {
P a, b;
L(const P &a_, const P &b_): a(a_), b(b_) {}
const P& operator[](size_t i) const { return i ? b : a; }
};
inline int ccw(const P& a, const P& b, const P& c) {
int ax = b.x - a.x, ay = b.y - a.y, bx = c.x - a.x, by = c.y - a.y;
P::T2 t = (P::T2)ax*by - (P::T2)ay*bx;
if (t > 0) return 1;
if (t < 0) return -1;
if((P::T2)ax*bx + (P::T2)ay*by < 0) return +2;
if((P::T2)ax*ax + (P::T2)ay*ay < (P::T2)bx*bx + (P::T2)by*by) return -2;
return 0;
}
vector<P> convex_hull(vector<P> ps) {
int n = ps.size(), k = 0;
sort(ps.begin(), ps.end());
vector<P> ch(2*n);
for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
ch.resize(k-1);
return ch;
}
ll convex_diameter(const vector<P> &pt) {
const int n = pt.size();
int is = 0, js = 0;
for (int i = 1; i < n; ++i) {
if(pt[i].y > pt[is].y) is = i;
if(pt[i].y < pt[js].y) js = i;
}
ll maxd = norm(pt[is]-pt[js]);
int i, maxi, j, maxj;
i = maxi = is;
j = maxj = js;
do {
if (cross((pt[(i+1)%pt.size()]-pt[i]), (pt[(j+1)%pt.size()]-pt[j])) >= 0) j = (j+1) % n;
else i = (i+1) % n;
if (norm(pt[i]-pt[j]) > maxd) {
maxd = norm(pt[i]-pt[j]);
maxi = i; maxj = j;
}
}while (i != is || j != js);
return maxd;
}
int main() {
int N;
cin >> N;
vector<int> X(N), Y(N);
rep(i, N)
scanf("%d%d", &X[i], &Y[i]);
if(N == 0) {
puts("1");
return 0;
}
vector<bool> bv(20021*20021);
map<int,int> a;
rep(i, N) {
int p = pack(Y[i],X[i]);
a.insert(mp(p, i));
bv[p] = true;
}
vector<bool> vis(N);
ll maxd = 0;
vector<P> points;
vi stk;
rep(s, N) if(!vis[s]) {
stk.clear();
points.clear();
stk.push_back(s);
vis[s] = true;
bv[pack(Y[s], X[s])] = false;
// cerr << s << ": " << endl;
while(!stk.empty()) {
int i = stk.back(); stk.pop_back();
int y0 = Y[i], x0 = X[i];
// cerr << "\t" << i << endl;
points.push_back(P(x0, y0));
int p0 = pack(y0, x0);
rep(k, C) {
int p = p0 + circle[k];
if(bv[p]) {
auto it = a.find(p);
if(it != a.end()) {
int j = it->second;
if(!vis[j]) {
stk.push_back(j);
vis[j] = true;
}
bv[p] = false;
}
}
}
}
if(points.size() >= 2) {
vector<P> ch = convex_hull(points);
ll d = convex_diameter(ch);
amax(maxd, d);
}
}
double ans = sqrt(maxd * 1.) + 2;
printf("%.10f\n", ans);
return 0;
}
anta