結果
問題 | No.1382 Travel in Mitaru city |
ユーザー | marroncastle |
提出日時 | 2021-02-07 22:02:49 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,291 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 101,844 KB |
最終ジャッジ日時 | 2024-07-04 15:33:26 |
合計ジャッジ時間 | 13,486 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
51,968 KB |
testcase_01 | AC | 37 ms
52,224 KB |
testcase_02 | AC | 37 ms
52,608 KB |
testcase_03 | AC | 38 ms
52,480 KB |
testcase_04 | AC | 37 ms
52,480 KB |
testcase_05 | AC | 38 ms
52,352 KB |
testcase_06 | WA | - |
testcase_07 | AC | 157 ms
77,404 KB |
testcase_08 | WA | - |
testcase_09 | AC | 165 ms
77,248 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 257 ms
91,136 KB |
testcase_28 | AC | 251 ms
91,008 KB |
testcase_29 | AC | 258 ms
91,384 KB |
testcase_30 | AC | 265 ms
90,908 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 131 ms
89,344 KB |
testcase_37 | AC | 82 ms
76,544 KB |
testcase_38 | AC | 134 ms
91,008 KB |
testcase_39 | AC | 87 ms
78,208 KB |
testcase_40 | AC | 120 ms
86,120 KB |
testcase_41 | AC | 124 ms
87,936 KB |
testcase_42 | AC | 147 ms
90,880 KB |
testcase_43 | AC | 145 ms
89,600 KB |
testcase_44 | AC | 95 ms
81,024 KB |
testcase_45 | AC | 124 ms
87,572 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 121 ms
85,504 KB |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | AC | 68 ms
72,576 KB |
testcase_62 | AC | 38 ms
52,864 KB |
testcase_63 | AC | 82 ms
76,416 KB |
testcase_64 | AC | 68 ms
74,496 KB |
testcase_65 | AC | 53 ms
63,360 KB |
testcase_66 | AC | 68 ms
72,064 KB |
testcase_67 | AC | 67 ms
72,832 KB |
testcase_68 | AC | 72 ms
76,160 KB |
testcase_69 | AC | 66 ms
72,320 KB |
testcase_70 | AC | 73 ms
76,160 KB |
ソースコード
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def same(self, x, y): return self.find(x) == self.find(y) def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def size(self,x): return abs(self.parents[self.find(x)]) def groups(self): roots = self.roots() r_to_g = {} for i, r in enumerate(roots): r_to_g[r] = i groups = [[] for _ in roots] for i in range(self.n): groups[r_to_g[self.find(i)]].append(i) return groups N, M, S, T = map(int, input().split()) P = list(map(int, input().split())) uf = UnionFind(N) for i in range(M): a,b = map(int, input().split()) uf.union(a-1,b-1) lis = uf.members(S-1) s = set() for l in lis: s.add(P[l]) s = list(s) s.sort() print(s.index(P[S-1]))