Task: | Tietoverkko |
Sender: | Tipu |
Submission time: | 2021-10-14 09:54:57 +0300 |
Language: | Python3 (CPython3) |
Status: | READY |
Result: | 10 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 10 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
def määritä(a, b, x, pienimmät): # print("määritys") i = 0 store = [row[:] for row in pienimmät] while i < len(pienimmät): if not store[i][a] == 0: if store[i][a] < x: # print("yksi") pienimmät[i][b] = pienimmät[i][a] pienimmät[b][i] = pienimmät[a][i] else: pienimmät[i][b] = x pienimmät[b][i] = x # print("kaksi", i) if not store[i][b] == 0: if store[i][b] < x: pienimmät[i][a] = pienimmät[i][b] pienimmät[a][i] = pienimmät[b][i] # print("kolme") else: pienimmät[i][a] = x pienimmät[a][i] = x # print("neljä", i) i += 1 pienimmät[a][b] = x pienimmät[b][a] = x # print(pienimmät) return pienimmät def laske(verkko): # print(verkko) i = 1 luku = 0 for kone in verkko[:-1]: saveI = i while i < len(kone) - 1: # print(kone[i],kone, i) luku += kone[i] i += 1 i = saveI + 1 return luku def main(): n = int(input()) # print(n) i = 0 a = [] b = [] x = [] pienimmät = [[0 for x in range(n+1)] for y in range(n+1)] while i < n - 1: abx = input().split(" ") a.append(int(abx[0])) b.append(int(abx[1])) x.append(int(abx[2])) # print(a, b, x) i += 1 i = 0 while i < n - 1: pienimmät = määritä(a[i] - 1, b[i] - 1, x[i], pienimmät) i += 1 print(laske(pienimmät)) # print("moi") main()
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 1 2 74 1 3 100 2 4 50 3 5 40 ... |
correct output |
---|
88687 |
user output |
---|
88687 |
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) |