| Task: | Tietoverkko |
| Sender: | jogr |
| Submission time: | 2021-10-04 16:40:03 +0300 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.03 s | 1, 2, 3 | details |
| #2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
n=int(input())
total_nconn = n * (n-1)
conn = [dict()] * n
for i in range(0, n-1):
c1, c2, sp = map(int, input().split())
c1 -= 1
c2 -= 1
conn[c1][c2] = sp
conn[c2][c1] = sp
s=0
def find_connection(c1, c2):
while not c2 in conn[c1].keys():
if c2 in conn[oth].keys():
conn[c1][c2] = conn[oth][c2]
conn[c2][c1] = conn[oth][c2]
for oth in conn[c1].keys():
find_connection(oth, c2)
return conn[c1][c2]
for c in range(0, n-1):
for o in range(c, n-1):
s += find_connection(c, o)
print(s)
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 100 1 2 74 1 3 100 2 4 50 3 5 40 ... |
| correct output |
|---|
| 88687 |
| user output |
|---|
| 247852 |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 5000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
| correct output |
|---|
| 1103702320243776 |
| user output |
|---|
| (empty) |
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) |
