結果
問題 | No.1382 Travel in Mitaru city |
ユーザー | marroncastle |
提出日時 | 2021-02-07 22:07:11 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,285 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 97,224 KB |
最終ジャッジ日時 | 2024-07-04 15:40:49 |
合計ジャッジ時間 | 13,257 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,096 KB |
testcase_01 | AC | 36 ms
52,096 KB |
testcase_02 | AC | 38 ms
52,224 KB |
testcase_03 | AC | 39 ms
51,968 KB |
testcase_04 | AC | 39 ms
51,968 KB |
testcase_05 | AC | 36 ms
52,608 KB |
testcase_06 | WA | - |
testcase_07 | AC | 152 ms
77,312 KB |
testcase_08 | WA | - |
testcase_09 | AC | 166 ms
77,056 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 | 260 ms
90,752 KB |
testcase_28 | AC | 255 ms
91,120 KB |
testcase_29 | AC | 262 ms
90,880 KB |
testcase_30 | AC | 262 ms
91,008 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 134 ms
88,832 KB |
testcase_37 | AC | 81 ms
77,056 KB |
testcase_38 | AC | 138 ms
90,368 KB |
testcase_39 | AC | 88 ms
78,428 KB |
testcase_40 | AC | 121 ms
86,144 KB |
testcase_41 | AC | 125 ms
87,296 KB |
testcase_42 | AC | 137 ms
90,496 KB |
testcase_43 | AC | 132 ms
89,216 KB |
testcase_44 | AC | 99 ms
80,768 KB |
testcase_45 | AC | 127 ms
87,552 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 120 ms
84,864 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,448 KB |
testcase_62 | AC | 39 ms
52,608 KB |
testcase_63 | AC | 83 ms
75,888 KB |
testcase_64 | AC | 70 ms
74,240 KB |
testcase_65 | AC | 54 ms
63,360 KB |
testcase_66 | AC | 67 ms
71,808 KB |
testcase_67 | AC | 67 ms
72,960 KB |
testcase_68 | AC | 74 ms
76,244 KB |
testcase_69 | AC | 67 ms
71,808 KB |
testcase_70 | AC | 75 ms
76,416 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)))