結果

問題 No.168 ものさし
ユーザー Div9851Div9851
提出日時 2017-09-20 20:13:28
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,275 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 161,112 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 21:17:57
合計ジャッジ時間 4,280 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
LL X[1000];
LL Y[1000];
struct UnionFind {
	int *par;
	int *rank;
	int size;
	UnionFind(int n) :size(n) {
		par = new int(size);
		rank = new int(size);
		rep(i, size) par[i] = i, rank[i] = 0;
	}
	void clear() {
		rep(i, size) par[i] = i, rank[i] = 0;
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
int main() {
	int N;
	cin >> N;
	rep(i, N) {
		cin >> X[i] >> Y[i];
	}
	LL l = 0, r = 2 * 100000000;
	UnionFind U(N);
	while (r - l > 1) {
		LL m = (l + r) / 2;
		U.clear();
		rep(i, N) {
			rep(j, N) {
				if ((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]) <= (m*10)*(m*10)) {
					U.unite(i, j);
				}
			}
		}
		if (U.same(0, N - 1)) r = m;
		else l = m;
	}
	cout << r*10 << endl;
}
0