結果
問題 | No.2179 Planet Traveler |
ユーザー | rlangevin |
提出日時 | 2023-03-19 00:16:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,590 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 81,904 KB |
実行使用メモリ | 78,100 KB |
最終ジャッジ日時 | 2023-10-18 17:37:49 |
合計ジャッジ時間 | 15,817 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,948 KB |
testcase_01 | AC | 38 ms
53,884 KB |
testcase_02 | AC | 37 ms
53,948 KB |
testcase_03 | AC | 37 ms
53,884 KB |
testcase_04 | AC | 37 ms
53,948 KB |
testcase_05 | AC | 37 ms
53,948 KB |
testcase_06 | AC | 38 ms
53,884 KB |
testcase_07 | WA | - |
testcase_08 | AC | 94 ms
76,424 KB |
testcase_09 | AC | 98 ms
76,496 KB |
testcase_10 | AC | 84 ms
76,424 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 1,013 ms
77,488 KB |
testcase_14 | AC | 396 ms
77,872 KB |
testcase_15 | AC | 399 ms
77,792 KB |
testcase_16 | AC | 402 ms
77,700 KB |
testcase_17 | AC | 1,036 ms
77,232 KB |
testcase_18 | AC | 1,054 ms
77,488 KB |
testcase_19 | AC | 1,050 ms
77,488 KB |
testcase_20 | AC | 240 ms
77,304 KB |
testcase_21 | AC | 980 ms
77,488 KB |
testcase_22 | AC | 688 ms
77,684 KB |
testcase_23 | AC | 602 ms
77,156 KB |
testcase_24 | AC | 877 ms
77,104 KB |
testcase_25 | AC | 710 ms
77,224 KB |
testcase_26 | AC | 948 ms
77,380 KB |
testcase_27 | AC | 248 ms
77,220 KB |
testcase_28 | AC | 503 ms
77,224 KB |
testcase_29 | AC | 942 ms
78,100 KB |
ソースコード
from math import sqrt class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] 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 union(self, x, y): x = self.find(x) y = self.find(y) if x != y: if self.rank[x] < self.rank[y]: x, y = y, x if self.rank[x] == self.rank[y]: self.rank[x] += 1 self.par[y] = x self.size[x] += self.size[y] def is_same(self, x, y): return self.find(x) == self.find(y) def get_size(self, x): x = self.find(x) return self.size[x] def dist1(i, j): return (X[i] - X[j]) ** 2 + (Y[i] - Y[j]) ** 2 def dist2(i, j): return abs(sqrt(X[i] ** 2 + Y[i] ** 2) - sqrt(X[j] ** 2 + Y[j] ** 2)) N = int(input()) X, Y, T = [0] * N, [0] * N, [0] * N for i in range(N): X[i], Y[i], T[i] = map(int, input().split()) yes = 10 ** 18 + 5 no = -1 eps = 10**-5 while yes - no != 1: mid = (yes + no)//2 U = UnionFind(N) for i in range(N): for j in range(i + 1, N): if T[i] != T[j]: if dist2(i, j) ** 2 - eps <= mid: U.union(i, j) else: if dist1(i, j) <= mid: U.union(i, j) if U.is_same(0, N - 1): yes = mid else: no = mid print(yes)