結果
問題 | No.2532 Want Play More |
ユーザー |
|
提出日時 | 2023-06-09 13:29:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,008 ms / 2,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,116 KB |
実行使用メモリ | 369,940 KB |
最終ジャッジ日時 | 2024-09-13 07:00:11 |
合計ジャッジ時間 | 12,359 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
import sysdef DFS(now,where):if tree[now]=={where} or len(tree[now])==0:return 0,0else:mini=[]maxi=[]for i in tree[now]:if i!=where:small,large=DFS(i,now)mini.append(small+1)maxi.append(large+1)return min(maxi),max(mini)sys.setrecursionlimit(500000)N=int(input())tree=[set() for i in range(N)]for i in range(N-1):a,b=map(int,input().split())tree[a-1].add(b-1)tree[b-1].add(a-1)second,first=DFS(0,-1)print(first)print(second)