結果

問題 No.168 ものさし
ユーザー knewknowlknewknowl
提出日時 2015-04-24 07:30:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 889 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 59,432 KB
実行使用メモリ 11,256 KB
最終ジャッジ日時 2023-09-18 08:51:48
合計ジャッジ時間 1,757 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,312 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 5 ms
7,276 KB
testcase_12 AC 7 ms
9,812 KB
testcase_13 AC 10 ms
11,076 KB
testcase_14 AC 10 ms
11,104 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,572 KB
testcase_19 AC 10 ms
10,948 KB
testcase_20 AC 11 ms
11,256 KB
testcase_21 AC 10 ms
11,088 KB
testcase_22 AC 10 ms
11,136 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;
  }
  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(true){
    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 && G[idx][i]<INF){
	d[i]=min(d[i],max(m,G[idx][i]));
      }
    }
  }
  cout << mysqrt(d[n-1]) << endl;
  return 0;
}
0