結果

問題 No.168 ものさし
ユーザー btkbtk
提出日時 2015-06-11 23:43:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,251 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 20,324 KB
最終ジャッジ日時 2023-08-25 20:57:12
合計ジャッジ時間 2,560 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
6,904 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 21 ms
6,688 KB
testcase_12 AC 78 ms
17,888 KB
testcase_13 AC 114 ms
19,668 KB
testcase_14 AC 113 ms
19,580 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 109 ms
19,508 KB
testcase_20 AC 117 ms
20,120 KB
testcase_21 AC 113 ms
19,700 KB
testcase_22 AC 116 ms
20,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<vector>
#include<functional>

using namespace std;

typedef long long LL;
typedef pair<LL, LL> PI;
typedef vector<PI> VP;
typedef pair<LL, int> PL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


#define x(_v) _v.first
#define y(_v) _v.second
#define cost(_v) _v.first
#define to(_v) _v.second
#define mp(_x,_y) make_pair(_x,_y)
#define dist(_v,_u) (x(_v)-x(_u))*(x(_v)-x(_u))+(y(_v)-y(_u))*(y(_v)-y(_u))
const LL INF = 2*(LL)1e9;
int main(){
	int N;
	cin >> N;
	VP p(N);
	for (auto& v: p){
		cin >> x(v) >> y(v);
	}
	VVLL edge(N, VLL(N));
	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			edge[i][j] = dist(p[i], p[j]);
		}
	}
	priority_queue<PL,vector<PL>,greater<PL>> que;
	vector<LL> used(N, -1);
	que.push(mp(0, 0));

	while (que.empty() == false){
		auto v = que.top(); que.pop();
		if (used[to(v)]>=0)continue;
		used[to(v)] = cost(v);
		for (int i = 0; i < N; i++){
			if (to(v)!=i&&used[i]==-1){
				que.push(mp(max(used[to(v)],edge[to(v)][i]), i));
			}
		}
	}
	LL res = used[N - 1];
	LL l = 0;
	LL h = INF;
	while (h - l > 1){
		LL m = ((l + h) / 2)*10;
		if (res <= m*m)h = m / 10;
		else l = m / 10;
	}
	cout << h * 10 << endl;


	return 0;
}
0