結果

問題 No.168 ものさし
ユーザー pekempeypekempey
提出日時 2015-08-18 17:23:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,209 bytes
コンパイル時間 1,258 ms
コンパイル使用メモリ 147,728 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-25 20:58:43
合計ジャッジ時間 2,530 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,388 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,384 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 33 ms
4,380 KB
testcase_13 AC 46 ms
4,376 KB
testcase_14 AC 45 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 29 ms
4,380 KB
testcase_20 AC 30 ms
4,376 KB
testcase_21 AC 32 ms
4,376 KB
testcase_22 AC 31 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

struct UF {
	vector<int> parent, size;
	UF(int n) : parent(n), size(n, 1) {
		rep (i, n) parent[i] = i;
	}
	int root(int x) {
		if (x == parent[x]) return x;
		else return parent[x] = root(parent[x]);
	}
	void unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return;
		if (size[x] > size[y]) swap(x, y);
		size[x] += size[y];
		parent[y] = x;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

int N;
ll X[1000], Y[1000];

ll hypot2(ll x, ll y) {
	return x * x + y * y;
}

int main() {
	cin >> N;
	rep (i, N) cin >> X[i] >> Y[i];

	ll l = 0, r = 2e8;	

	while (r - l > 1) {
		ll m = (l + r) / 2;
		UF uf(N);

		rep (i, N) {
			rep2 (j, i + 1, N) {
				if (hypot2(X[j] - X[i], Y[j] - Y[i]) <= 100 * m * m) {
					uf.unite(i, j);	
				}
			}
		}

		if (uf.same(0, N - 1)) {
			r = m;	
		} else {
			l = m;
		}
	}

	cout << r * 10 << endl;

	return 0;
}
0