結果

問題 No.168 ものさし
ユーザー Div9851Div9851
提出日時 2017-09-20 20:30:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 1,249 bytes
コンパイル時間 1,167 ms
コンパイル使用メモリ 146,212 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 21:06:20
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 19 ms
4,380 KB
testcase_12 AC 60 ms
4,376 KB
testcase_13 AC 84 ms
4,376 KB
testcase_14 AC 83 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 46 ms
4,376 KB
testcase_20 AC 48 ms
4,384 KB
testcase_21 AC 50 ms
4,376 KB
testcase_22 AC 49 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;
	UnionFind(int n) {
		par = new int[n];
		rank = new int[n];
		rep(i, n) par[i] = i, rank[i] = 0;
	}
	void clear(int n) {
		rep(i, n) par[i] = i, rank[i] = 0;
	}
	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);
	}
	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 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;
		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;
		U.clear(N);
	}
	cout << r*10 << endl;
}
0