結果
| 問題 | No.2532 Want Play More |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-09 13:29:48 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 692 ms / 2,000 ms |
| + 313µs | |
| コード長 | 508 bytes |
| 記録 | |
| コンパイル時間 | 2,161 ms |
| コンパイル使用メモリ | 95,344 KB |
| 実行使用メモリ | 360,192 KB |
| 最終ジャッジ日時 | 2026-08-26 00:30:35 |
| 合計ジャッジ時間 | 10,874 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
import sys
def DFS(now,where):
if tree[now]=={where} or len(tree[now])==0:
return 0,0
else:
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)