結果

問題 No.2354 Poor Sight in Winter
ユーザー shobonvipshobonvip
提出日時 2023-06-16 22:11:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,187 bytes
コンパイル時間 4,405 ms
コンパイル使用メモリ 267,072 KB
実行使用メモリ 5,508 KB
最終ジャッジ日時 2023-09-06 20:10:23
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 58 ms
5,244 KB
testcase_12 AC 61 ms
5,224 KB
testcase_13 AC 78 ms
5,388 KB
testcase_14 AC 73 ms
5,412 KB
testcase_15 AC 65 ms
5,300 KB
testcase_16 AC 68 ms
5,508 KB
testcase_17 AC 67 ms
5,280 KB
testcase_18 AC 28 ms
4,380 KB
testcase_19 AC 53 ms
4,788 KB
testcase_20 AC 33 ms
4,460 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 14 ms
4,380 KB
testcase_23 AC 16 ms
4,376 KB
testcase_24 AC 44 ms
4,776 KB
testcase_25 AC 11 ms
4,380 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef modint998244353 mint;
typedef long long ll;

int main(){
	int n, k; cin >> n >> k;
	n += 2;
	int sx, sy; cin >> sx >> sy;
	int gx, gy; cin >> gx >> gy;
	vector<int> x(n), y(n);
	for (int i=0; i<n-2; i++){
		cin >> x[i+1] >> y[i+1];
	}
	x[0] = sx;
	y[0] = sy;
	x[n-1] = gx;
	y[n-1] = gy;

	int ub = 300000;
	int lb = 0;
	while (ub - lb > 1){
		int targ = (ub + lb) / 2;
		vector ikeru(n, vector<pair<int,int>>(0));
		for (int i=0; i<n; i++){
			for (int j=i+1; j<n; j++){
				int trg = abs(x[i] - x[j]) + abs(y[i] - y[j]);
				int req = (trg + targ - 1) / targ - 1;
				ikeru[i].push_back(pair(j, req));
				ikeru[j].push_back(pair(i, req));
			}
		}
		vector<int> d(n, 1e9);
		priority_queue<pair<int,int>> pq;
		pq.push(pair(0, 0));
		d[0] = 0;
		while(!pq.empty()){
			auto [tmp, i] = pq.top();
			pq.pop();
			tmp = -tmp;
			if (tmp > d[i]) continue;
			for (auto [j, dist] : ikeru[i]){
				int res = tmp + dist;
				if (res < d[j]){
					d[j] = res;
					pq.push(pair(-res, j));
				}
			}
		}
		if (d[n-1] <= k){
			ub = targ;
		}else{
			lb = targ;
		}
	}
	cout << ub << endl;

}
0