結果
| 問題 |
No.168 ものさし
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-11-23 12:58:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 913 bytes |
| コンパイル時間 | 2,168 ms |
| コンパイル使用メモリ | 196,644 KB |
| 最終ジャッジ日時 | 2025-01-06 17:11:23 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 5 TLE * 14 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
Int n;
cin>>n;
vector<Int> x(n),y(n);
for(Int i=0;i<n;i++) cin>>x[i]>>y[i];
auto dist=
[&](Int a,Int b){
Int v=(x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]);
Int d=(Int)sqrtl(v)/10*10;
while((d-10)*(d-10)>=v) d-=10;
while(d*d<v) d+=10;
return d;
};
const Int INF = 1e15;
vector<Int> dp(n,INF),used(n,0);
dp[0]=0;
for(Int t=0;t<n;t++){
Int v=-1;
for(Int i=0;i<n;i++){
if(used[i]) continue;
if(v<0||dp[v]>dp[i]) v=i;
}
if(v<0) break;
used[v]=1;
for(Int i=0;i<n;i++)
chmin(dp[i],max(dp[v],dist(v,i)));
}
cout<<dp[n-1]<<endl;
return 0;
}
beet