Submission #14968549


Source Code Expand

Copy
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int, read().split())
UV = tuple(zip(m, m))

ans = 0
for n in range(1, N + 1):
    ans += n * (N - n + 1)
for a, b in UV:
    if a > b:
        a, b = b, a
    ans -= a * (N - b + 1)
print(ans)

Submission Info

Submission Time
Task F - Intervals on Tree
User maspy
Language Python (3.8.2)
Score 600
Code Size 355 Byte
Status
Exec Time 262 ms
Memory 59320 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 600 / 600 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 28 ms 9184 KB
02.txt 19 ms 8948 KB
03.txt 31 ms 8948 KB
04.txt 28 ms 9112 KB
05.txt 28 ms 9112 KB
06.txt 24 ms 9112 KB
07.txt 28 ms 9104 KB
08.txt 26 ms 9184 KB
09.txt 25 ms 9112 KB
10.txt 30 ms 9060 KB
11.txt 230 ms 43276 KB
12.txt 241 ms 59076 KB
13.txt 246 ms 59068 KB
14.txt 255 ms 59076 KB
15.txt 239 ms 51520 KB
16.txt 248 ms 59084 KB
17.txt 196 ms 49308 KB
18.txt 106 ms 26196 KB
19.txt 262 ms 59320 KB
20.txt 251 ms 59256 KB
21.txt 244 ms 59088 KB
22.txt 243 ms 59008 KB
23.txt 235 ms 59192 KB
s1.txt 26 ms 9112 KB
s2.txt 30 ms 9120 KB
s3.txt 25 ms 9116 KB