結果

問題 No.2532 Want Play More
ユーザー ニックネームニックネーム
提出日時 2023-11-03 23:21:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,155 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 11,684 KB
実行使用メモリ 87,244 KB
最終ジャッジ日時 2023-11-03 23:22:05
合計ジャッジ時間 16,397 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,076 KB
testcase_01 AC 1,155 ms
43,316 KB
testcase_02 AC 1,148 ms
43,336 KB
testcase_03 AC 1,116 ms
41,988 KB
testcase_04 AC 1,092 ms
41,628 KB
testcase_05 AC 1,060 ms
40,728 KB
testcase_06 AC 950 ms
87,244 KB
testcase_07 AC 42 ms
10,600 KB
testcase_08 AC 61 ms
11,364 KB
testcase_09 AC 56 ms
11,160 KB
testcase_10 AC 505 ms
25,632 KB
testcase_11 AC 488 ms
25,352 KB
testcase_12 AC 854 ms
34,860 KB
testcase_13 AC 597 ms
28,304 KB
testcase_14 AC 199 ms
16,216 KB
testcase_15 AC 1,150 ms
42,892 KB
testcase_16 AC 933 ms
37,868 KB
testcase_17 AC 51 ms
10,972 KB
testcase_18 AC 707 ms
31,492 KB
testcase_19 AC 946 ms
38,620 KB
testcase_20 AC 28 ms
10,076 KB
testcase_21 AC 29 ms
10,076 KB
testcase_22 AC 28 ms
10,076 KB
testcase_23 AC 29 ms
10,076 KB
testcase_24 AC 28 ms
10,076 KB
testcase_25 AC 28 ms
10,076 KB
testcase_26 AC 28 ms
10,076 KB
testcase_27 AC 28 ms
10,076 KB
testcase_28 AC 824 ms
38,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit
setrecursionlimit(10**6)
n = int(input()); adj = [[] for _ in range(n)]
for _ in range(n-1):
    u,v = map(int,input().split())
    adj[u-1].append(v-1); adj[v-1].append(u-1)
def dfs(v,p):
    if len(adj[v])==0 or v!=0 and len(adj[v])==1: return 0,0
    ma = 1; mi = n
    for c in adj[v]:
        if c==p: continue
        x,y = dfs(c,v); ma = max(ma,y+1); mi = min(mi,x+1)
    return ma,mi
print(*dfs(0,-1),sep="\n")
0