結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2015-12-29 15:21:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 1,626 bytes |
コンパイル時間 | 1,481 ms |
コンパイル使用メモリ | 166,644 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-12-24 07:12:32 |
合計ジャッジ時間 | 2,923 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>typedef long long ll;typedef unsigned long long ull;#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)#define REP(i,n) FOR(i,0,n)#define RANGE(vec) (vec).begin(),(vec).end()using namespace std;class Ruler {public:void solve(void) {int N;cin>>N;vector<ll> xs(N);vector<ll> ys(N);REP(i,N){cin>>xs[i]>>ys[i];}vector<vector<ll>> dist(N,vector<ll>(N,0));REP(i,N)REP(j,i+1){ll dx = xs[i]-xs[j];ll dy = ys[i]-ys[j];// (10^9)^2 を double で扱うと精度落ちするので long long で扱うdist[i][j] = dist[j][i] = dx*dx+dy*dy;}ll low = 0;ll high = 2*1E+9+1;vector<bool> vis(N,false);while (low+1 < high){ll mid = (low+high)/2;fill(RANGE(vis),false);function<void(int)> dfs = [&](int v) {vis[v] = true;REP(u,N){if (vis[u])continue;if (dist[v][u] > mid*mid)continue;dfs(u);}};dfs(0);if (vis[N-1])high = mid;elselow = mid;}cout<<(ll)ceil(high/10.0)*10<<endl;}};#if 1int main(int argc, char *argv[]){ios::sync_with_stdio(false);auto obj = new Ruler();obj->solve();delete obj;return 0;}#endif