結果
問題 | No.1382 Travel in Mitaru city |
ユーザー | Mitarushi |
提出日時 | 2021-02-04 22:08:20 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,474 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 87,356 KB |
実行使用メモリ | 102,068 KB |
最終ジャッジ日時 | 2023-09-17 06:31:37 |
合計ジャッジ時間 | 29,990 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
71,392 KB |
testcase_01 | AC | 68 ms
71,044 KB |
testcase_02 | AC | 69 ms
71,140 KB |
testcase_03 | AC | 68 ms
70,952 KB |
testcase_04 | AC | 69 ms
71,040 KB |
testcase_05 | WA | - |
testcase_06 | AC | 281 ms
83,444 KB |
testcase_07 | AC | 252 ms
82,372 KB |
testcase_08 | AC | 223 ms
80,724 KB |
testcase_09 | AC | 295 ms
83,984 KB |
testcase_10 | AC | 289 ms
83,464 KB |
testcase_11 | WA | - |
testcase_12 | AC | 521 ms
92,048 KB |
testcase_13 | AC | 539 ms
92,228 KB |
testcase_14 | AC | 499 ms
90,964 KB |
testcase_15 | AC | 505 ms
91,512 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 734 ms
98,312 KB |
testcase_19 | WA | - |
testcase_20 | AC | 706 ms
98,264 KB |
testcase_21 | AC | 689 ms
98,272 KB |
testcase_22 | AC | 693 ms
98,332 KB |
testcase_23 | AC | 703 ms
98,260 KB |
testcase_24 | AC | 704 ms
98,644 KB |
testcase_25 | AC | 730 ms
98,512 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | AC | 562 ms
95,772 KB |
testcase_52 | AC | 649 ms
98,728 KB |
testcase_53 | AC | 257 ms
82,644 KB |
testcase_54 | AC | 365 ms
87,920 KB |
testcase_55 | AC | 638 ms
97,264 KB |
testcase_56 | AC | 309 ms
84,900 KB |
testcase_57 | AC | 467 ms
91,312 KB |
testcase_58 | AC | 211 ms
80,972 KB |
testcase_59 | AC | 302 ms
84,556 KB |
testcase_60 | AC | 604 ms
98,132 KB |
testcase_61 | WA | - |
testcase_62 | AC | 76 ms
71,216 KB |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
ソースコード
class UnionFind: def __init__(self, n): self.parent = [-1] * n self.rank = [1] * n self.count = [1] * n def get_root(self, i): while self.parent[i] != -1: i = self.parent[i] return i def is_same_tree(self, i, j): return self.get_root(i) == self.get_root(j) def merge(self, i, j): i = self.get_root(i) j = self.get_root(j) if i == j: return if self.rank[i] > self.rank[j]: self.parent[j] = i self.rank[i] = max(self.rank[i], self.rank[j] + 1) self.count[i] += self.count[j] else: self.parent[i] = j self.rank[j] = max(self.rank[j], self.rank[i] + 1) self.count[j] += self.count[i] n, m, s, t = map(int, input().split()) s -= 1 t -= 1 p = [(int(i), ind) for ind, i in enumerate(input().split())] p.sort(reverse=True) e = [[] for _ in range(n)] for _ in range(m): a, b = [int(i) - 1 for i in input().split()] e[a].append(b) e[b].append(a) uf = UnionFind(n) dp = [-float("inf")] * n used = [False] * n for _, ind in p: used[ind] = True if ind == s: a = 0 else: a = -float("inf") for j in e[ind]: if used[j]: a = max(a, dp[uf.get_root(j)]) a += 1 for j in e[ind]: if used[j]: uf.merge(ind, j) dp[uf.get_root(ind)] = a print(dp[uf.get_root(t)])