結果

問題 No.168 ものさし
ユーザー motimoti
提出日時 2015-04-09 13:07:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,079 bytes
コンパイル時間 1,247 ms
コンパイル使用メモリ 149,228 KB
実行使用メモリ 11,080 KB
最終ジャッジ日時 2023-09-17 19:00:08
合計ジャッジ時間 3,527 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 112 ms
8,496 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 129 ms
10,948 KB
testcase_21 AC 143 ms
10,764 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

struct UnionFind
{
	vector<int> rank;
	vector<int> rid;

	UnionFind(int n) {
		rank.resize(n);
		rid.assign(n, -1);
	}

	void unite(int u, int v) {
		u = root(u), v = root(v);
		if(u == v) { return ; }
		if(rank[u] < rank[v]) {
			rid[u] = v;
		}
		else {
			rid[v] = u;
			if(rank[u] == rank[v]) {
				rank[u]++;
			}
		}
	}

	bool same(int u, int v) {
		return root(u) == root(v);
	}

	int root(int x) {
		if(rid[x] < 0) return x;
		else return rid[x] = root(rid[x]);
	}
};

typedef long long ll;

ll N;
ll px[1010], py[1010];

#define SQ(x) ((x)*(x))

bool OK(ll x) {

	UnionFind uni(N*N);

	rep(i, N) {
		REP(j, i+1, N) {
			if(SQ(px[i]-px[j])+SQ(py[i]-py[j]) <= x*x) {
				uni.unite(i, j);
			}
		}
	}

	return uni.same(0, N-1);
}

int main() {

	cin >> N;

	rep(i, N) {
		cin >> px[i] >> py[i];
	}

	ll L = 0, R = 1e9;
	while(R-L>1) {
		ll M = (L+R)/2;
		if(OK(M)) {
			R = M;
		}
		else {
			L = M;
		}
	}

	cout << (R+5)/10*10 << endl;

	return 0;
}
0