Submission #1691317


Source Code Expand

def arc84_d(n,A):
    road = 0
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if A[i][j] > A[i][k] + A[k][j]:
                    return -1
                elif A[i][j] == A[i][k] + A[k][j]:
                    if k not in {i,j} and i < j:
                        road += A[i][j]
    return road

n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
road = arc84_d(n,A)
print(road)

Submission Info

Submission Time
Task D - Restoring Road Network
User kalstun
Language Python (3.4.3)
Score 0
Code Size 472 Byte
Status WA
Exec Time 2104 ms
Memory 6772 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
WA × 2
AC × 6
WA × 3
TLE × 8
Set Name Test Cases
Sample subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt
Case Name Status Exec Time Memory
01.txt TLE 2104 ms 6644 KB
02.txt TLE 2104 ms 6644 KB
03.txt TLE 2104 ms 6644 KB
04.txt TLE 2104 ms 6644 KB
05.txt TLE 2104 ms 6644 KB
06.txt TLE 2104 ms 6644 KB
07.txt AC 38 ms 6644 KB
08.txt TLE 2104 ms 6644 KB
09.txt TLE 2104 ms 6644 KB
10.txt AC 38 ms 6772 KB
11.txt AC 38 ms 6772 KB
12.txt AC 38 ms 6644 KB
13.txt WA 17 ms 3064 KB
subtask0_0.txt AC 17 ms 3064 KB
subtask0_1.txt AC 17 ms 3064 KB
subtask0_2.txt WA 17 ms 3064 KB
subtask0_3.txt WA 17 ms 3064 KB