結果

問題 No.168 ものさし
ユーザー krotonkroton
提出日時 2015-01-08 01:01:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 150,696 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 20:41:22
合計ジャッジ時間 2,364 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;

const ll INF = LLONG_MAX;

int N;
ll X[1111], Y[1111], dist[1111];

ll max_dijkstra(int s, int t){
	priority_queue<P, vector<P>, greater<P>> Q;

	for(int i=0;i<N;i++)dist[i] = INF;
	dist[s] = 0;
	
	Q.push(P(0, s));
	while(!Q.empty()){
		P ps = Q.top(); Q.pop();

		ll mx = ps.first;
		int v = ps.second;

		if(dist[v] < mx)continue;
		for(int i=0;i<N;i++){
			ll dx = X[v] - X[i];
			ll dy = Y[v] - Y[i];
			ll d = dx * dx + dy * dy;

			ll nxt = max(mx, d);
			if(dist[i] > nxt){
				dist[i] = nxt;
				Q.push(P(nxt, i));
			}
		}
	}

	return dist[t];
}

int main(){
	cin >> N;
	for(int i=0;i<N;i++)cin >> X[i] >> Y[i];

	ll min_diff = max_dijkstra(0, N - 1);

	ll res = max(0ll, (ll)sqrt(min_diff) - 5);
	while(res * res < min_diff)++res;

	res = (res + 10 - 1) / 10 * 10;
	cout << res << endl;

	return 0;
}
0