結果
問題 | No.1382 Travel in Mitaru city |
ユーザー | rlangevin |
提出日時 | 2023-03-02 12:35:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,221 bytes |
コンパイル時間 | 593 ms |
コンパイル使用メモリ | 81,224 KB |
実行使用メモリ | 92,012 KB |
最終ジャッジ日時 | 2023-10-17 09:51:47 |
合計ジャッジ時間 | 18,204 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,452 KB |
testcase_01 | AC | 38 ms
53,452 KB |
testcase_02 | AC | 38 ms
53,452 KB |
testcase_03 | AC | 38 ms
53,452 KB |
testcase_04 | AC | 38 ms
53,452 KB |
testcase_05 | AC | 37 ms
53,452 KB |
testcase_06 | WA | - |
testcase_07 | AC | 142 ms
76,784 KB |
testcase_08 | WA | - |
testcase_09 | AC | 150 ms
76,784 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 | 267 ms
91,708 KB |
testcase_28 | AC | 264 ms
91,780 KB |
testcase_29 | AC | 261 ms
91,780 KB |
testcase_30 | AC | 256 ms
91,780 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 100 ms
89,312 KB |
testcase_37 | AC | 69 ms
76,208 KB |
testcase_38 | AC | 105 ms
91,364 KB |
testcase_39 | AC | 73 ms
77,772 KB |
testcase_40 | AC | 92 ms
86,104 KB |
testcase_41 | AC | 97 ms
87,700 KB |
testcase_42 | AC | 105 ms
91,396 KB |
testcase_43 | AC | 99 ms
89,272 KB |
testcase_44 | AC | 77 ms
79,608 KB |
testcase_45 | AC | 95 ms
87,612 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 99 ms
84,680 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 | 51 ms
66,364 KB |
testcase_62 | AC | 38 ms
53,452 KB |
testcase_63 | AC | 60 ms
75,488 KB |
testcase_64 | AC | 51 ms
66,364 KB |
testcase_65 | AC | 43 ms
61,100 KB |
testcase_66 | AC | 49 ms
64,316 KB |
testcase_67 | AC | 50 ms
66,364 KB |
testcase_68 | AC | 52 ms
68,412 KB |
testcase_69 | AC | 50 ms
64,316 KB |
testcase_70 | AC | 53 ms
70,460 KB |
ソースコード
import sys readline = sys.stdin.readline 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] N, M, S, T = map(int, readline().split()) S, T = S - 1, T - 1 P = list(map(int, readline().split())) U = UnionFind(N) for i in range(M): A, B = map(int, readline().split()) A, B = A - 1, B - 1 U.union(A, B) SS = set() for i in range(N): if U.find(i) != U.find(S): continue if P[i] < P[S]: SS.add(P[i]) print(len(SS))