CSES - Datatähti 2022 alku - Results
Submission details
Task:Tietoverkko
Sender:Jellu
Submission time:2021-10-17 23:21:35 +0300
Language:CPython3
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.02 s1, 2, 3details
#20.02 s2, 3details
#30.02 s3details

Code

etaisyydet = {1:10**9 + 1}
summa = 0
arvot = {}
matkat = {1:"1"}
matka_arvot = {1:10**9 + 1}
pienet_arvot = {}
n = int(input())
for i in range(n-1):
        a,b,x = [int(x) for x in input().split()]
        etaisyydet[max(a,b)] = x
        matkat[b] = matkat[a]+str(b)
        if a not in arvot:
            arvot[a] = []
        for j in arvot:
            if str(j) in matkat[b]:
                if len(arvot[j]) != 0:
                    kohta = matkat[b][matkat[b].find(str(j))+1:][:len(arvot[j])]
                else:
                    kohta = matkat[b][matkat[b].find(str(j))+1:]
                arvo = etaisyydet[b]
                try:
                    arvo = min(pienet_arvot[j][kohta], arvo)
                except KeyError:
                    pienet_arvot[j] = {}
                pienet_arvot[j][kohta] = arvo
                for k in arvot[j]:
                    k_kohta = k.find("!")
                    if k[0] != kohta[0]:
                        summa += min(int(k[k.find("!")+1:]), arvo)
                nimi = f"{kohta}!{arvo}"
                arvot[j].append(nimi)
                summa += arvo
print(summa)

Test details

Test 1

Group: 1, 2, 3

Verdict:

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 28, in <module>
    if k[0] != kohta[0]:
IndexError: string index out of range

Test 2

Group: 2, 3

Verdict:

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 28, in <module>
    if k[0] != kohta[0]:
IndexError: string index out of range

Test 3

Group: 3

Verdict:

input
200000
1 2 613084013
1 3 832364259
2 4 411999902
3 5 989696303
...

correct output
1080549209850010931

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 28, in <module>
    if k[0] != kohta[0]:
IndexError: string index out of range