結果

問題 No.168 ものさし
ユーザー kurenaifkurenaif
提出日時 2016-08-30 21:25:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,801 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 94,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 21:18:44
合計ジャッジ時間 2,936 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 44 ms
5,376 KB
testcase_12 AC 133 ms
5,376 KB
testcase_13 AC 189 ms
5,376 KB
testcase_14 AC 187 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 10 ms
5,376 KB
testcase_19 AC 141 ms
5,376 KB
testcase_20 AC 147 ms
5,376 KB
testcase_21 AC 157 ms
5,376 KB
testcase_22 AC 151 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

class union_find {
private:
	vector<int> par;
	vector<int> rank;
public:
	union_find(int N):par(N), rank(N) {
		for (int i = 0; i < N; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	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]++;
		}
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

template <class T>
struct vector2 {
	T x;
	T y;
	vector2(T x_, T y_) :x(x_), y(y_) {}
	vector2() :x(0), y(0) {}
	vector2 operator + (const vector2<T>& right) { return vector2(x + right.x, y + right.y); }
	vector2 operator - (const vector2<T>& right) { return vector2(x - right.x, y - right.y); }
	T dot(const vector2<T>& right) { return x*right.x + y*right.y; }
	T det(const vector2<T>& right) { return (x*right.y) + (-y*right.x); }
	T dist2(const vector2<T>& right) { return (right.x-x)*(right.x-x) + (right.y-y)*(right.y-y); }
	T ownDot(const vector2<T>& right) { return x*x+y*y; }
};

int main() {
	int N; cin >> N;
	vector<vector2<double> > P(N); REP(i, N) cin >> P[i].x >> P[i].y;

	double low = 0.0, high = 10e9*2;
	REP(count, 100) {
		double mid = (low + high) / 2.0;
		union_find uf(N);
		REP(i, N) REP(j, N) {
			if (P[i].dist2(P[j]) <= mid*mid) {
				uf.unite(i, j);
			}
		}
		if (uf.same(0, N - 1)) high = mid;
		else low = mid;
	}
	cout << int(ceil((low + high) / 20.0))*10 << endl;
	return 0;
}
0