| Task: | Tietoverkko |
| Sender: | tassu |
| Submission time: | 2021-10-05 17:17:10 +0300 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.03 s | 1, 2, 3 | details |
| #2 | RUNTIME ERROR | 0.57 s | 2, 3 | details |
| #3 | RUNTIME ERROR | 0.28 s | 3 | details |
Code
import math
l = int(input())
speeds = [[0] * l for i in range(l)]
for i in range(l - 1):
a, b, x = map(int, input().split(' '))
speeds[a - 1][b - 1] = x
speeds[b - 1][a - 1] = x
def find_lowest(unvisited, distances):
smallest_key, smallest_value = 0, math.inf
for key in unvisited:
value = distances[key]
if value < smallest_value:
smallest_key = key
return smallest_key
def speeds_for(initial):
unvisited = list(range(l))
distance = [0 if i == initial else math.inf for i in unvisited]
speeds = [math.inf for _ in unvisited]
unvisited.remove(initial)
current = initial
speed_counter = 0
while True:
current_distance = distance[current]
current_speed = speeds[current]
for j in unvisited:
speed = speeds[j][current]
if speed == 0:
continue
distance[j] = current_distance + 1
min_speed = min(current_speed, speed)
speeds[j] = min_speed
speed_counter += min_speed
if len(unvisited) == 0:
break
current = find_lowest(unvisited, distance)
unvisited.remove(current)
return speed_counter
total_speed = 0
for i in range(l):
total_speed += speeds_for(i)
print(int(total_speed / 2))
Test details
Test 1
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100 1 2 74 1 3 100 2 4 50 3 5 40 ... |
| correct output |
|---|
| 88687 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 57, in <module>
total_...Test 2
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 5000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
| correct output |
|---|
| 1103702320243776 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 57, in <module>
total_...Test 3
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
| correct output |
|---|
| 1080549209850010931 |
| user output |
|---|
| (empty) |
