結果
| 問題 | No.2532 Want Play More |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-11-26 03:38:02 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 934 ms / 2,000 ms |
| + 201µs | |
| コード長 | 694 bytes |
| 記録 | |
| コンパイル時間 | 91 ms |
| コンパイル使用メモリ | 64,456 KB |
| 実行使用メモリ | 329,344 KB |
| 最終ジャッジ日時 | 2026-11-26 03:38:15 |
| 合計ジャッジ時間 | 11,675 ms |
|
ジャッジサーバーID (参考情報) |
judge1_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)
adj = [[] for _ in range(N)]
for _ in range(N-1):
U, V = map(lambda x: int(x)-1, input().split())
adj[U].append(V)
adj[V].append(U)
HALC = 0
SAPP = 1
def tree_dp(v, par, side):
res = -INF if side == HALC else INF
for to in adj[v]:
if to == par: continue
r = tree_dp(to, v, side ^ 1) + 1
if side == HALC:
res = max(res, r)
else:
res = min(res, r)
if res in (-INF, INF):
return 0
return res
a = tree_dp(0, -1, HALC)
b = tree_dp(0, -1, SAPP)
print(a)
print(b)
norioc