結果

問題 No.168 ものさし
ユーザー t_hashimoto1104t_hashimoto1104
提出日時 2017-11-16 12:31:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 60,552 KB
実行使用メモリ 11,404 KB
最終ジャッジ日時 2023-08-25 21:06:26
合計ジャッジ時間 1,500 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,556 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 4 ms
7,448 KB
testcase_12 AC 8 ms
10,188 KB
testcase_13 AC 11 ms
11,164 KB
testcase_14 AC 11 ms
11,152 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,648 KB
testcase_19 AC 11 ms
11,008 KB
testcase_20 AC 11 ms
11,200 KB
testcase_21 AC 11 ms
11,204 KB
testcase_22 AC 11 ms
11,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define INF 2000000000000000100
ll G[1000][1000];
ll d[1000],x[1000],y[1000];
int n;
bool visited[1000];
ll mysqrt(ll t){
  ll a=0,b=1500000000;
  for(int i=0;i<100;++i){
    ll r=(a+b+1)/2;
    if(r*r<=t) a=r;
    else b=r;
  }
  if(a*a==t) return (a+9)/10*10;
  return (b+9)/10*10;
}
int main(){
  cin>>n;
  for(int i=0;i<n;++i) cin>>x[i]>>y[i];
  for(int i=0;i<n;++i) for(int j=0;j<n;++j) G[i][j] = (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);

  for(int i=1;i<n;++i) d[i]=INF;
  while(1){
    int idx=-1;
    ll m=INF;
    for(int i=0;i<n;++i){
      if(m > d[i] && !visited[i]){
	        idx = i;
	        m = d[i];
      }
    }
    if(idx==-1) break;
    visited[idx]=true;
    for(int i=0;i<n;++i){
      if(G[idx][i]!=0)	d[i]=min(d[i],max(m,G[idx][i]));
    }
  }
    cout << mysqrt(d[n-1]) << endl;
  return 0;
}
0