| Task: | Tietoverkko |
| Sender: | jmarttinen |
| Submission time: | 2021-10-05 09:44:14 +0300 |
| Language: | Python3 (PyPy3) |
| 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.13 s | 1, 2, 3 | details |
| #2 | RUNTIME ERROR | 0.20 s | 2, 3 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
n = int(input())
graph_dict = {i : [] for i in range(1, n+1)}
graph = []
for _ in range(n-1):
inp = tuple(map(int, input().split()))
graph.append(inp)
graph_dict[inp[0]].append(inp[1])
graph_dict[inp[1]].append(inp[0])
def search_main():
s = 0
graph.sort(key=lambda x: x[2])
while len(graph) > 0:
l,r = 1, 1
m = graph[0]
graph.pop(0)
graph_dict[m[0]].remove(m[1])
graph_dict[m[1]].remove(m[0])
for n in graph_dict[m[0]]:
l += search(n, [m[0]])
for n in graph_dict[m[1]]:
r += search(n, [m[1]])
s += l*r * m[2]
return s
def search(node, checked=[]):
if len(list(filter(lambda x: x not in checked, graph_dict[node]))) == 0:
return 1
l = 0
for n in graph_dict[node]:
checked.append(n)
l += search(n, checked)
return l
print(search_main())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 45, in <module>
print(...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 45, in <module>
print(...Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
| correct output |
|---|
| 1080549209850010931 |
| user output |
|---|
| (empty) |
