結果

問題 No.168 ものさし
ユーザー ttkkggwwttkkggww
提出日時 2022-08-17 17:37:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 4,459 ms
コンパイル使用メモリ 258,080 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 06:43:15
合計ジャッジ時間 5,606 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 13 ms
6,940 KB
testcase_12 AC 38 ms
6,940 KB
testcase_13 AC 52 ms
6,940 KB
testcase_14 AC 53 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 4 ms
6,940 KB
testcase_19 AC 25 ms
6,944 KB
testcase_20 AC 25 ms
6,944 KB
testcase_21 AC 25 ms
6,940 KB
testcase_22 AC 26 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
}
0