結果
問題 | No.168 ものさし |
ユーザー |
|
提出日時 | 2022-08-17 17:37:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 705 bytes |
コンパイル時間 | 4,467 ms |
コンパイル使用メモリ | 252,952 KB |
最終ジャッジ日時 | 2025-01-30 23:31:21 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include<atcoder/all>using namespace atcoder;using ll = long long;int n;using P = pair<ll,ll>;vector<P> p;bool isconnect(ll x){dsu UF(n);for(int i = 0;i<n;i++){for(int j = i+1;j<n;j++){ll dx = p[i].first - p[j].first;ll dy = p[i].second - p[j].second;if(dx*dx+dy*dy<=x*x){UF.merge(i,j);}}}if(UF.same(0,n-1))return true;return false;}void solve(){ll l = 0 , r = 200000000;while(r-l>1){ll m = (l+r)/2;if(isconnect(m*10))r = m;else l = m;}cout<<r*10<<endl;}signed main(){cin.tie(nullptr);ios::sync_with_stdio(false);cin >> n;p = vector<P>(n);for(auto &[l,r]:p)cin >> l >> r;solve();}