結果
問題 |
No.2912 0次パーシステントホモロジー
|
ユーザー |
👑 |
提出日時 | 2024-07-22 21:22:20 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,150 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 334 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 51,156 KB |
最終ジャッジ日時 | 2024-10-04 20:50:47 |
合計ジャッジ時間 | 6,945 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
I,R=input,range J=lambda:map(int,I().split()) N,M=J() E=[list(J())for j in R(M)] E=sorted([w,u,v]for u,v,w in E) T=int(I()) Q=list(J()) Q=sorted([Q[t],t]for t in R(T)) A=[0]*T e=0 c=N P=list(R(N)) H=[0]*N def r(i): m=P[i] while i!=m:P[i]=i=P[m];m=P[i] return i for[q,t]in Q: while e<M: w,u,v=E[e] if w>q:break else: u,v,e=r(u),r(v),e+1 if H[v]<H[u]:u,v=v,u H[v]+=H[u]==H[v];P[u]=v;c-=u!=v A[t]=c for a in A:print(a)