結果
問題 | No.1382 Travel in Mitaru city |
ユーザー | 👑 Kazun |
提出日時 | 2021-02-07 21:40:09 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,685 bytes |
コンパイル時間 | 268 ms |
コンパイル使用メモリ | 87,068 KB |
実行使用メモリ | 105,300 KB |
最終ジャッジ日時 | 2023-09-17 20:58:55 |
合計ジャッジ時間 | 26,816 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 90 ms
71,824 KB |
testcase_01 | AC | 90 ms
71,576 KB |
testcase_02 | AC | 91 ms
71,592 KB |
testcase_03 | AC | 92 ms
71,604 KB |
testcase_04 | AC | 91 ms
71,532 KB |
testcase_05 | AC | 89 ms
71,600 KB |
testcase_06 | WA | - |
testcase_07 | AC | 232 ms
83,024 KB |
testcase_08 | WA | - |
testcase_09 | AC | 251 ms
84,348 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 | 481 ms
100,208 KB |
testcase_28 | AC | 491 ms
101,376 KB |
testcase_29 | AC | 470 ms
101,828 KB |
testcase_30 | AC | 373 ms
98,664 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 239 ms
95,340 KB |
testcase_37 | AC | 142 ms
80,520 KB |
testcase_38 | AC | 254 ms
97,428 KB |
testcase_39 | AC | 162 ms
83,672 KB |
testcase_40 | AC | 211 ms
92,016 KB |
testcase_41 | AC | 224 ms
93,676 KB |
testcase_42 | AC | 246 ms
97,612 KB |
testcase_43 | AC | 224 ms
95,276 KB |
testcase_44 | AC | 171 ms
85,240 KB |
testcase_45 | AC | 212 ms
93,348 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 297 ms
92,256 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 | 116 ms
78,176 KB |
testcase_62 | AC | 89 ms
71,816 KB |
testcase_63 | AC | 137 ms
79,240 KB |
testcase_64 | AC | 116 ms
78,164 KB |
testcase_65 | AC | 102 ms
77,348 KB |
testcase_66 | AC | 115 ms
77,924 KB |
testcase_67 | AC | 114 ms
78,272 KB |
testcase_68 | AC | 121 ms
78,228 KB |
testcase_69 | AC | 114 ms
77,768 KB |
testcase_70 | AC | 121 ms
78,092 KB |
ソースコード
class Union_Find(): def __init__(self,N): """0,1,...,n-1を要素として初期化する. N:要素数 """ self.n=N self.parents=[-1]*N self.rank=[0]*N def find(self, x): """要素xの属している族を調べる. x:要素 """ V=[] while self.parents[x]>=0: V.append(x) x=self.parents[x] for v in V: self.parents[v]=x return x def union(self, x, y): """要素x,yを同一視する. x,y:要素 """ x=self.find(x) y=self.find(y) if x==y: return if self.rank[x]<self.rank[y]: x,y=y,x self.parents[x]+=self.parents[y] self.parents[y]=x if self.rank[x]==self.rank[y]: self.rank[x]+=1 def size(self, x): """要素xの属している要素の数. x:要素 """ return -self.parents[self.find(x)] def same(self, x, y): """要素x,yは同一視されているか? x,y:要素 """ return self.find(x) == self.find(y) def members(self, x): """要素xが属している族の要素. ※族の要素の個数が欲しいときはsizeを使うこと!! x:要素 """ root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): """族の名前のリスト """ return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): """族の個数 """ return len(self.roots()) def all_group_members(self): """全ての族の出力 """ X={r:[] for r in self.roots()} for k in range(self.n): X[self.find(k)].append(k) return X def refresh(self): for i in range(self.n): _=self.find(i) def __str__(self): return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) def __repr__(self): return self.__str__() #================================================ from collections import defaultdict import sys input=sys.stdin.readline N,M,S,T=map(int,input().split()) P=["*"]+list(map(int,input().split())) E=[[] for _ in range(N+1)] for _ in range(M): a,b=map(int,input().split()) E[a].append(b) E[b].append(a) U=Union_Find(N+1) F=sorted(range(1,N+1),key=lambda x:P[x],reverse=True) Flag=defaultdict(int) Ans=0 for x in F: for y in E[x]: U.union(x,y) if P[x]<P[S] and U.same(x,S) and Flag[P[x]]==0: Ans+=1 Flag[P[x]]=1 print(Ans)