結果
問題 | No.1382 Travel in Mitaru city |
ユーザー | marroncastle |
提出日時 | 2021-02-07 22:07:11 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,285 bytes |
コンパイル時間 | 540 ms |
コンパイル使用メモリ | 87,100 KB |
実行使用メモリ | 98,844 KB |
最終ジャッジ日時 | 2023-09-17 21:52:57 |
合計ジャッジ時間 | 17,076 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
71,476 KB |
testcase_01 | AC | 75 ms
71,292 KB |
testcase_02 | AC | 73 ms
71,292 KB |
testcase_03 | AC | 74 ms
71,180 KB |
testcase_04 | AC | 75 ms
71,276 KB |
testcase_05 | AC | 74 ms
71,248 KB |
testcase_06 | WA | - |
testcase_07 | AC | 193 ms
78,144 KB |
testcase_08 | WA | - |
testcase_09 | AC | 206 ms
78,336 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 | 311 ms
92,188 KB |
testcase_28 | AC | 306 ms
92,408 KB |
testcase_29 | AC | 308 ms
92,448 KB |
testcase_30 | AC | 318 ms
92,296 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 167 ms
90,128 KB |
testcase_37 | AC | 118 ms
78,308 KB |
testcase_38 | AC | 173 ms
91,764 KB |
testcase_39 | AC | 128 ms
80,360 KB |
testcase_40 | AC | 154 ms
86,824 KB |
testcase_41 | AC | 160 ms
88,424 KB |
testcase_42 | AC | 172 ms
91,804 KB |
testcase_43 | AC | 164 ms
89,772 KB |
testcase_44 | AC | 132 ms
82,112 KB |
testcase_45 | AC | 158 ms
88,280 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 154 ms
85,168 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 | 101 ms
76,808 KB |
testcase_62 | AC | 75 ms
71,316 KB |
testcase_63 | AC | 114 ms
76,952 KB |
testcase_64 | AC | 105 ms
77,248 KB |
testcase_65 | AC | 89 ms
75,608 KB |
testcase_66 | AC | 101 ms
76,884 KB |
testcase_67 | AC | 103 ms
77,284 KB |
testcase_68 | AC | 106 ms
77,152 KB |
testcase_69 | AC | 102 ms
76,912 KB |
testcase_70 | AC | 106 ms
76,988 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: if P[l]<P[S-1]: s.add(P[l]) print(len(list(s)))