結果
問題 |
No.2677 Minmax Independent Set
|
ユーザー |
![]() |
提出日時 | 2025-07-20 03:57:53 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 634 bytes |
コンパイル時間 | 576 ms |
コンパイル使用メモリ | 82,352 KB |
実行使用メモリ | 91,284 KB |
最終ジャッジ日時 | 2025-07-20 03:58:03 |
合計ジャッジ時間 | 9,697 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 -- * 2 |
other | -- * 61 |
ソースコード
n=int(input()) e=[[] for i in range(n)] for i in range(n-1): u,v=map(int,input().split()) u-=1 v-=1 e[u]+=[v] e[v]+=[u] v=[0]*n u=[[0,0] for i in range(n)] q=[0] while len(q)>0: s=q[-1] if v[s]==0: v[s]=1 q+=[t for t in e[s] if v[t]==0] else: u[s][0]=sum(max(u[t]) for t in e[s] if v[t]==0) u[s][1]=sum(u[t][0] for t in e[s] if v[t]==0)+1 v[s]=0 q.pop() q=[0] v[0]=1 while len(q)>0: for t in e[s]: if v[t]==0: q+=[t] v[t]=1 nu0=max(u[s][0]-max(u[t]),u[s][1]-u[t][0]) nu1=u[s][0]-max(u[t]) u[t][0]+=nu0 u[t][1]+=nu1 print(min(u[i][1] for i in range(n)))