結果

問題 No.168 ものさし
ユーザー vain0vain0
提出日時 2015-06-01 19:50:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,580 bytes
コンパイル時間 862 ms
コンパイル使用メモリ 96,272 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 20:56:54
合計ジャッジ時間 2,107 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cassert>
#include <functional>
#include <set>
#include <ctime>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#ifndef ONLINE_JUDGE //POJ
# include <random>
# include <array>
# define mkt make_tuple
# define empb emplace_back
#endif
#ifdef _LOCAL
# include "for_local.h"
#endif
using namespace std;
typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))
#define mkp make_pair
#define all(_X) (_X).begin(), (_X).end()
#define scani(_V) std::scanf("%d", &_V)
#define printi(_V) std::printf("%d", static_cast<int>(_V))

int const INF = 1<<29;
ll selfprod(ll x, ll y) { return x * x + y * y; }

int n;
vector<pair<int,int>> ps;
bool pred(ll len) {
	vector<bool> done(n, false);
	priority_queue<int> qs;
	qs.push(0);
	done[0] = true;
	while ( !qs.empty() ) {
		int q = qs.top(); qs.pop();
		rep(i, n) {
			if ( !done[i]
				&& selfprod(ps[q].first - ps[i].first, ps[q].second - ps[i].second) <= len * len ) {
				if ( i == n - 1 ) return true;
				qs.push(i);
				done[i] = true;
			}
		}
	}
	return false;
}

//O(n (log n)^2)
signed main() {
	cin >> n;
	rep(i, n) {
		int x, y;
		cin >> x >> y;
		ps.push_back(mkp(x,y));
	}
	ll low = 1, high = (ll)(1e9);
	rep(_, 50) {
		ll mid = low + (high - low) / 2;
		(pred(mid * 10) ? high : low) = mid;
	}
	cout << (high * 10) << endl;
	return 0;
}
0