結果
| 問題 | No.2532 Want Play More |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-11-26 03:09:41 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 984 ms / 2,000 ms |
| + 23µs | |
| コード長 | 631 bytes |
| 記録 | |
| コンパイル時間 | 82 ms |
| コンパイル使用メモリ | 64,588 KB |
| 実行使用メモリ | 345,040 KB |
| 最終ジャッジ日時 | 2026-11-26 03:09:56 |
| 合計ジャッジ時間 | 13,743 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
INF = 1 << 62
N = int(input())
adj = defaultdict(list)
for _ in range(N-1):
U, V = map(lambda x: int(x)-1, input().split())
adj[U].append(V)
adj[V].append(U)
def tree_dp(v, par, turn):
res = -INF if turn == 0 else INF
for to in adj[v]:
if to == par: continue
r = tree_dp(to, v, turn ^ 1) + 1
if turn == 0:
res = max(res, r)
else:
res = min(res, r)
if res in (-INF, INF):
return 0
return res
a = tree_dp(0, -1, 0)
b = tree_dp(0, -1, 1)
print(a)
print(b)
norioc