結果

問題 No.2354 Poor Sight in Winter
ユーザー Heart_BlueHeart_Blue
提出日時 2023-06-16 22:36:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,782 ms / 2,000 ms
コード長 1,685 bytes
コンパイル時間 997 ms
コンパイル使用メモリ 120,376 KB
実行使用メモリ 5,732 KB
最終ジャッジ日時 2023-09-06 20:57:55
合計ジャッジ時間 15,304 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1,034 ms
5,476 KB
testcase_12 AC 840 ms
5,608 KB
testcase_13 AC 1,716 ms
5,652 KB
testcase_14 AC 1,781 ms
5,732 KB
testcase_15 AC 1,597 ms
5,516 KB
testcase_16 AC 1,691 ms
5,512 KB
testcase_17 AC 1,782 ms
5,540 KB
testcase_18 AC 316 ms
4,560 KB
testcase_19 AC 874 ms
5,208 KB
testcase_20 AC 350 ms
4,708 KB
testcase_21 AC 9 ms
4,380 KB
testcase_22 AC 129 ms
4,396 KB
testcase_23 AC 145 ms
4,436 KB
testcase_24 AC 700 ms
4,920 KB
testcase_25 AC 74 ms
4,380 KB
testcase_26 AC 51 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 6 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e2 + 10;
int a[N][N];
int d[N][N];
pair<int, int> vp[N];
void floyd(int n)
{
	for (int k = 0; k <= n; k++)
	{
		for (int i = 0; i <= n; i++)
		{
			for (int j = 0; j <= n; j++)
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
		}
	}
}
inline int dis(int i, int j)
{
	return abs(vp[i].first - vp[j].first) + abs(vp[i].second - vp[j].second);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	scanf("%d%d", &n, &k);
	scanf("%d%d%d%d", &vp[0].first, &vp[0].second, &vp[n + 1].first, &vp[n + 1].second);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &vp[i].first, &vp[i].second);
	n++;
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
			d[i][j] = dis(i, j);
	}
	int l = 1, r = dis(0, n);
	int ans = r;
	while (l <= r)
	{
		int mid = (l + r) / 2;
		for (int i = 0; i <= n; i++)
		{
			for (int j = 0; j <= n; j++)
			{
				int d = ::d[i][j] - mid;
				d = max(0, d);
				a[i][j] = (d + mid - 1) / (mid);
			}
		}
		floyd(n);
		if (a[0][n] <= k) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n", ans);
	return 0;
}
0