結果

問題 No.2532 Want Play More
ユーザー titiatitia
提出日時 2023-11-07 02:02:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 919 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 11,880 KB
実行使用メモリ 92,004 KB
最終ジャッジ日時 2023-11-07 02:02:20
合計ジャッジ時間 13,220 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,100 KB
testcase_01 AC 919 ms
43,356 KB
testcase_02 AC 911 ms
43,360 KB
testcase_03 AC 834 ms
42,012 KB
testcase_04 AC 807 ms
41,668 KB
testcase_05 AC 806 ms
40,768 KB
testcase_06 AC 704 ms
92,004 KB
testcase_07 AC 58 ms
10,624 KB
testcase_08 AC 49 ms
11,384 KB
testcase_09 AC 45 ms
11,184 KB
testcase_10 AC 354 ms
25,656 KB
testcase_11 AC 387 ms
25,376 KB
testcase_12 AC 648 ms
34,900 KB
testcase_13 AC 454 ms
28,344 KB
testcase_14 AC 146 ms
16,240 KB
testcase_15 AC 871 ms
42,932 KB
testcase_16 AC 725 ms
37,908 KB
testcase_17 AC 43 ms
10,996 KB
testcase_18 AC 523 ms
31,532 KB
testcase_19 AC 738 ms
38,644 KB
testcase_20 AC 28 ms
10,100 KB
testcase_21 AC 28 ms
10,100 KB
testcase_22 AC 28 ms
10,100 KB
testcase_23 AC 29 ms
10,100 KB
testcase_24 AC 28 ms
10,100 KB
testcase_25 AC 27 ms
10,100 KB
testcase_26 AC 28 ms
10,100 KB
testcase_27 AC 28 ms
10,100 KB
testcase_28 AC 484 ms
38,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

sys.setrecursionlimit(10**7)

N=int(input())
E=[[] for i in range(N+1)]

for i in range(N-1):
    a,b=map(int,input().split())
    E[a].append(b)
    E[b].append(a)

def calc(point,parent,minmax):
    ANS=0
    for to in E[point]:
        if to==parent:
            continue

        if minmax==0:
            if ANS==0:
                ANS=1<<30
            ANS=min(ANS,1+calc(to,point,minmax^1))
        else:
            ANS=max(ANS,1+calc(to,point,minmax^1))
    return ANS

print(calc(1,-1,1))
print(calc(1,-1,0))
0