Submission #60827057


Source Code Expand

N = int(input())
T = [[] for _ in range(N)]
deg = [0] * N
for _ in range(N - 1):
    u, v = map(lambda x: int(x) - 1, input().split())
    T[u].append(v)
    T[v].append(u)
    deg[u] += 1
    deg[v] += 1
ans = N
for u in range(N):
    T[u].sort(key=lambda v: -deg[v])
    x = y = 0
    for v in T[u]:
        x += 1
        y = deg[v] - 1
        ans = min(ans, N - (1 + x + x * y))
print(ans)

Submission Info

Submission Time
Task E - Snowflake Tree
User sotanishy
Language Python (PyPy 3.10-v7.3.12)
Score 450
Code Size 413 Byte
Status AC
Exec Time 704 ms
Memory 155012 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 65 ms 76488 KiB
00_sample_02.txt AC 66 ms 76572 KiB
00_sample_03.txt AC 66 ms 76216 KiB
01_random_01.txt AC 704 ms 136856 KiB
01_random_02.txt AC 415 ms 113264 KiB
01_random_03.txt AC 691 ms 136192 KiB
01_random_04.txt AC 321 ms 104580 KiB
01_random_05.txt AC 681 ms 136520 KiB
01_random_06.txt AC 141 ms 87520 KiB
01_random_07.txt AC 687 ms 136220 KiB
01_random_08.txt AC 387 ms 110088 KiB
01_random_09.txt AC 678 ms 136372 KiB
01_random_10.txt AC 579 ms 127964 KiB
01_random_11.txt AC 637 ms 136736 KiB
01_random_12.txt AC 543 ms 127032 KiB
01_random_13.txt AC 622 ms 138976 KiB
01_random_14.txt AC 548 ms 127252 KiB
01_random_15.txt AC 650 ms 136812 KiB
01_random_16.txt AC 472 ms 126024 KiB
01_random_17.txt AC 575 ms 137160 KiB
01_random_18.txt AC 565 ms 132436 KiB
01_random_19.txt AC 666 ms 136728 KiB
01_random_20.txt AC 448 ms 121000 KiB
02_handmade_01.txt AC 528 ms 145688 KiB
02_handmade_02.txt AC 566 ms 140188 KiB
02_handmade_03.txt AC 540 ms 155012 KiB
02_handmade_04.txt AC 523 ms 145280 KiB
02_handmade_05.txt AC 543 ms 133760 KiB
02_handmade_06.txt AC 579 ms 135336 KiB