Submission #832310

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8323102023-08-21 08:45:55daniel604Harbingers (CEOI09_harbingers)Cpython 3
10 / 100
802 ms65536 KiB
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
N = int(input())
# vertex
vertex = [{} for _ in range(N + 1)]
for _ in range(N - 1):
U, V, D = map(int, input().split())
vertex[U][V] = D
vertex[V][U] = D
# S[i], V[i] i
S, V = [0] * (N + 1), [0] * (N + 1)
for i in range(N - 1):
s, v = map(int, input().split())
S[i + 2], V[i + 2] = s, v
# DFS
# DFS graph .
# .
# , ,
# graph graph graph
# graph lenght .
# dp[i] = min(-D[j] x V[i] + dp[j]) + S[i] + D[i] x V[i]
distance = [0] * (N + 1)
# child , (, y) -> (-distance[i], dp[i])
graph, lenght = [0] * N, 0
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...