結果

問題 No.1998 Manhattan Restaurant
ユーザー MasKoaTSMasKoaTS
提出日時 2022-03-19 16:29:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 738 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 601,720 KB
最終ジャッジ日時 2024-04-15 05:57:30
合計ジャッジ時間 9,874 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
17,696 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 27 ms
10,880 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 672 ms
39,680 KB
testcase_07 AC 1,226 ms
48,512 KB
testcase_08 AC 1,266 ms
48,640 KB
testcase_09 AC 1,283 ms
48,640 KB
testcase_10 AC 491 ms
33,792 KB
testcase_11 AC 115 ms
17,152 KB
testcase_12 AC 49 ms
12,160 KB
testcase_13 AC 72 ms
13,824 KB
testcase_14 AC 674 ms
47,360 KB
testcase_15 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
P = [list(map(int, input().split())) for _ in [0] * N]

route = [[] for _ in [0] * N]
for i in range(N - 1):
	for j in range(i + 1, N):
		d = abs(P[i][0] - P[j][0]) + abs(P[i][1] - P[j][1])
		route[i].append((j, d))
		route[j].append((i, d))

def func(d):
	c = [0] * N
	for v in range(N):
		if(c[v]):
			continue
		c[v] = 1
		que = [v]
		while(que):
			now = que.pop()
			for nv, nd in route[now]:
				if(nd <= d):
					continue
				if(c[nv] == 0):
					c[nv] = -c[now]
					que.append(nv)
				elif(c[nv] == c[now]):
					return False
	return True

ok = 4 * 10 ** 9 + 1
ng = 0
while(ok - ng > 1):
	d = (ok + ng) // 2
	if(func(d)):
		ok = d
	else:
		ng = d

ans = ok // 2
print(ans)
0