結果

問題 No.96 圏外です。
ユーザー LayCurseLayCurse
提出日時 2014-12-07 20:30:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 7,262 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 167,096 KB
実行使用メモリ 14,336 KB
最終ジャッジ日時 2024-06-06 15:39:15
合計ジャッジ時間 4,013 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,320 KB
testcase_01 AC 4 ms
8,448 KB
testcase_02 AC 4 ms
8,320 KB
testcase_03 AC 4 ms
8,192 KB
testcase_04 AC 6 ms
8,448 KB
testcase_05 AC 7 ms
8,704 KB
testcase_06 AC 8 ms
8,832 KB
testcase_07 AC 11 ms
8,832 KB
testcase_08 AC 13 ms
9,088 KB
testcase_09 AC 16 ms
9,344 KB
testcase_10 AC 25 ms
9,600 KB
testcase_11 AC 28 ms
10,112 KB
testcase_12 AC 29 ms
10,496 KB
testcase_13 AC 61 ms
10,752 KB
testcase_14 AC 59 ms
11,520 KB
testcase_15 AC 108 ms
12,032 KB
testcase_16 AC 98 ms
13,056 KB
testcase_17 AC 85 ms
14,336 KB
testcase_18 AC 131 ms
13,952 KB
testcase_19 AC 132 ms
13,952 KB
testcase_20 AC 111 ms
12,864 KB
testcase_21 AC 71 ms
12,304 KB
testcase_22 AC 124 ms
12,744 KB
testcase_23 AC 135 ms
12,564 KB
testcase_24 AC 5 ms
8,320 KB
testcase_25 AC 56 ms
12,416 KB
testcase_26 AC 75 ms
13,696 KB
testcase_27 AC 64 ms
13,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:133:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  133 |   rep(i,N) scanf("%lf%lf",&P[i].x,&P[i].y);
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

void unionInit(int d[],int s){int i;rep(i,s)d[i]=i;}
int unionGet(int d[],int n){int t=n,k;while(d[t]!=t)t=d[t];while(d[n]!=n)k=d[n],d[n]=t,n=k;return n;}
int unionConnect(int d[],int a,int b){a=unionGet(d,a);b=unionGet(d,b);if(a==b)return 0;d[a]=b;return 1;}

#define EPS 1e-8
#define PI 3.141592653589793238462
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
typedef struct struct_point{double x,y;}pnt;
typedef struct struct_line{pnt a,b;}line;
typedef struct struct_circle{pnt c; double r;}circle;

int doubleSign(double a){if(a>EPS) return 1; if(a<-EPS) return -1; return 0;}
int doubleSignR(double a,double b){ if(doubleSign(b)!=0 && doubleSign(a/b-1)==0) return 0; return doubleSign(a-b);}
int pntSign(pnt a){int i=doubleSign(a.x); if(i) return i; return doubleSign(a.y);}

pnt pntPlus(pnt a,pnt b){a.x+=b.x; a.y+=b.y; return a;}
pnt pntMinus(pnt a,pnt b){a.x-=b.x; a.y-=b.y; return a;}
pnt pntMultiple(pnt a,pnt b){pnt c; c.x=a.x*b.x-a.y*b.y; c.y=a.x*b.y+a.y*b.x; return c;}
pnt pntMultipleDouble(pnt a,double k){a.x*=k; a.y*=k; return a;}

int pntIsEqual(pnt a,pnt b){return pntSign(pntMinus(a,b))==0;}

double pntLength(pnt a){return sqrt(a.x*a.x+a.y*a.y);}
double pntLength2(pnt a){return a.x*a.x+a.y*a.y;}
double pntDistance(pnt a,pnt b){return pntLength(pntMinus(a,b));}
double pntDistance2(pnt a,pnt b){return pntLength2(pntMinus(a,b));}
double pntArgument(pnt a){return atan2(a.y,a.x);}

pnt pntNormalize(pnt a){double n=pntLength(a); a.x/=n; a.y/=n; return a;}
double pntInnerProduct(pnt a,pnt b){return a.x*b.x+a.y*b.y;}
double pntOuterProduct(pnt a,pnt b){return a.x*b.y-a.y*b.x;}

pnt pntGenerator(double x,double y){pnt res; res.x=x; res.y=y; return res;}
line pntToLine(pnt a,pnt b){line res; res.a=a; res.b=b; return res;}
circle pntToCircle(pnt c,double r){circle res; res.c=c; res.r=r; return res;}

int isPntInCircle(pnt p,circle c){return doubleSign(c.r-pntDistance(p,c.c))+1;}
int isPntOnCircle(pnt p,circle c){if(doubleSign(pntDistance(p,c.c)-c.r)==0) return 1; return 0;}

/* aがbの厳密に内部なら2 */
int isCircleInCircle(circle a,circle b){return doubleSign(b.r-a.r-pntDistance(a.c,b.c))+1;}

pnt pntPolar(double r,double t){pnt a; a.x=r*cos(t); a.y=r*sin(t); return a;}
void pntSort(pnt d[],int s){int i,j;pnt k,t;if(s<=1)return;k=pntMultipleDouble(pntPlus(d[0],d[s-1]),1/2.0);i=-1;j=s;for(;;){while(pntSign(pntMinus(d[++i],k))==-1);while(pntSign(pntMinus(d[--j],k))==1);if(i>=j)break;t=d[i];d[i]=d[j];d[j]=t;}pntSort(d,i);pntSort(d+j+1,s-j-1);}

/* 点oのまわりに点aをtだけ回転した点を返す */
pnt pntRatation(pnt a,pnt o,double t){
  return pntPlus(pntMultiple(pntMinus(a,o),pntPolar(1.0,t)),o);
}

pnt pntRatationEasy(pnt a,double t){
  return pntMultiple(a,pntPolar(1.0,t));
}


int N;
pnt P[200000];
int ind[200000];
pnt cnv[200000]; int cs;

vector<pnt> p[200000];
pnt c, v;

/* 点の進行方向 */
/* 1,-1は符号付き面積の符号と同じ */
/* 2 : c -- a -- b */
/* -2: a -- b -- c */
/* 0 : その他      */
int pntCCW(pnt a,pnt b,pnt c){
  double tmp;
  b=pntMinus(b,a); c=pntMinus(c,a);
  tmp = pntOuterProduct(b,c);
  if( doubleSign(tmp) ) return doubleSign( tmp );
  if( doubleSign( pntInnerProduct(b,c) ) == -1 ) return 2;
  if( doubleSign( pntLength(c)-pntLength(b) ) == 1 ) return -2;
  return 0;
}

/* convex hull (Andrew's Monotone Chain) */
/* 制約: size >= 3, pはsorted (x座標について) */
/* return 凸包の頂点数 */
/* たぶん,直線上の中点を含まない → pntCCW(res[res_size-2],res[res_size-1],p[i])<=0 */
/* たぶん,直線上の中点を含める   → pntCCW(res[res_size-2],res[res_size-1],p[i])==-1 */
int pntConvexHull(pnt p[],int size,pnt res[]){
  int i,res_size=0,t;
  for(i=0;i<size;res[res_size++]=p[i++])    while(res_size>=2 && pntCCW(res[res_size-2],res[res_size-1],p[i])<=0) res_size--;
  t=res_size;
  for(i=size-2;i>=0;res[res_size++]=p[i--]) while(res_size> t && pntCCW(res[res_size-2],res[res_size-1],p[i])<=0) res_size--;
  return res_size-1;
}


#define RED 0.985


int main(){
  int i, j, k, n;
  double res, tmp, now, nx;
  double move, mx; int mind;

  reader(&N);
  if(N==0){ puts("1.000"); return 0; }
  
  rep(i,N) scanf("%lf%lf",&P[i].x,&P[i].y);
  rep(i,N) P[i] = pntRatationEasy(P[i], 1);
  pntSort(P, N);

  unionInit(ind, N);
  rep(i,N) REP(j,i+1,N){
    if(P[j].x - 10 > P[i].x + EPS) break;
    if(pntDistance2(P[i],P[j]) <= 100+EPS) unionConnect(ind, i, j);
  }

  res = 0;
  rep(i,N){
    j = unionGet(ind,i);
    p[j].push_back(P[i]);
  }

  rep(k,N) if(p[k].size() > 1){
    n = 0;
    rep(i,p[k].size()) P[n++] = p[k][i];

    if(n > 4){
      cs = pntConvexHull(P, n, cnv);
      tmp = 0;
      j = 0;
      rep(i,cs){
        now = pntDistance2(cnv[i], cnv[j]);
        for(;;){
          nx = pntDistance2(cnv[i], cnv[(j+1)%cs]);
          if(nx > now) now = nx, j = (j+1)%cs;
          else break;
        }
        tmp = max(tmp, now);
      }
    } else {
      tmp = 0;
      rep(i,n) REP(j,i+1,n) tmp = max(tmp, pntDistance2(P[i],P[j]));
    }
    tmp = sqrt(tmp);
    res = max(res, tmp);
  }

  res += 2;
  printf("%.10f\n",res);

  return 0;
}
0