結果

問題 No.168 ものさし
ユーザー t_hashimoto1104t_hashimoto1104
提出日時 2017-11-16 12:44:15
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 905 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 59,924 KB
実行使用メモリ 16,288 KB
最終ジャッジ日時 2023-08-16 16:48:53
合計ジャッジ時間 7,114 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:17: warning: ‘idx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     visited[idx]=true;
     ~~~~~~~~~~~~^~~~~

ソースコード

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;
    ll m=INF;
    for(int i=0;i<n;++i){
      if(m > d[i] && !visited[i]){
	        idx = i;
	        m = d[i];
      }
    }
    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