結果

問題 No.168 ものさし
ユーザー 双六双六
提出日時 2020-07-27 02:11:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,221 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 139,684 KB
最終ジャッジ日時 2023-09-11 05:32:59
合計ジャッジ時間 16,997 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 426 ms
95,320 KB
testcase_01 AC 100 ms
71,800 KB
testcase_02 AC 100 ms
71,888 KB
testcase_03 AC 102 ms
71,932 KB
testcase_04 AC 102 ms
71,788 KB
testcase_05 WA -
testcase_06 AC 99 ms
71,796 KB
testcase_07 AC 101 ms
71,680 KB
testcase_08 WA -
testcase_09 AC 112 ms
76,976 KB
testcase_10 AC 132 ms
77,440 KB
testcase_11 AC 384 ms
93,512 KB
testcase_12 AC 1,296 ms
123,856 KB
testcase_13 AC 1,930 ms
139,340 KB
testcase_14 AC 1,893 ms
139,396 KB
testcase_15 AC 102 ms
71,676 KB
testcase_16 AC 111 ms
76,956 KB
testcase_17 AC 124 ms
77,424 KB
testcase_18 AC 158 ms
78,036 KB
testcase_19 AC 1,848 ms
139,684 KB
testcase_20 AC 1,911 ms
139,384 KB
testcase_21 AC 1,930 ms
139,320 KB
testcase_22 AC 1,908 ms
139,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")
import math

def getlist():
	return list(map(int, input().split()))

class UnionFind:
	def __init__(self, n):
		self.par = [i for i in range(n + 1)]
		self.rank = [0] * (n + 1)

	def find(self, x):
		if self.par[x] == x:
			return x
		else:
			self.par[x] = self.find(self.par[x])
			return self.par[x]

	def same_check(self, x, y):
		return self.find(x) == self.find(y)

	def union(self, x, y):
		x = self.find(x); y = self.find(y)
		if self.rank[x] < self.rank[y]:
			self.par[x] = y
		else:
			self.par[y] = x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1



#処理内容
def main():
	N = int(input())
	UF = UnionFind(N)
	node = []
	edge = []
	for i in range(N):
		X, Y = getlist()
		node.append([X, Y])

	for i in range(N):
		for j in range(i + 1, N):
			x1, y1 = node[i]
			x2, y2 = node[j]
			edge.append([math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) + 9.999999, i, j])

	edge.sort()
	ans = INF
	for dist, i, j in edge:
		UF.union(i, j)
		if UF.same_check(0, N - 1):
			ans = int(dist // 10) * 10
			break

	print(ans)


if __name__ == '__main__':
	main()
0