Submission #533439


Source Code Expand

#!/usr/bin/env python
# -*- coding: utf-8 -*-

T = int(input())
for t in range(T):
    N = int(input())
    G = [[float("inf") for i in range(N)] for j in range(N)]
    dist = [[float("inf") for i in range(N)] for j in range(N)]

    for i in range(N):
        for j,c in enumerate(map(int,input().split())):
            G[i][j] = c if c >= 0 else float("inf")

    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], G[i][k] + G[k][j])
    for i in range(N):
        if dist[i] != G[i]:
            break
    else:
        print("YES")
        continue
    print("NO")

Submission Info

Submission Time
Task C - 最短経路
User emon
Language Python (3.4.2)
Score 0
Code Size 666 Byte
Status WA
Exec Time 1234 ms
Memory 6868 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 37
WA × 4
Set Name Test Cases
All 00_sample.txt, 10_random_00.txt, 10_random_01.txt, 10_random_02.txt, 10_random_03.txt, 10_random_04.txt, 10_random_05.txt, 10_random_06.txt, 10_random_07.txt, 10_random_08.txt, 10_random_09.txt, 10_random_10.txt, 10_random_11.txt, 10_random_12.txt, 10_random_13.txt, 10_random_14.txt, 10_random_15.txt, 10_random_16.txt, 10_random_17.txt, 10_random_18.txt, 10_random_19.txt, 10_random_20.txt, 10_random_21.txt, 10_random_22.txt, 10_random_23.txt, 10_random_24.txt, 10_random_25.txt, 10_random_26.txt, 10_random_27.txt, 10_random_28.txt, 10_random_29.txt, 22_random_30.txt, 22_random_31.txt, 23_coplete_32.txt, 23_coplete_33.txt, 24_path_34.txt, 24_path_35.txt, 25_tree_36.txt, 25_tree_37.txt, 26_noedge_38.txt, 27_dot_39.txt
Case Name Status Exec Time Memory
00_sample.txt AC 118 ms 6684 KB
10_random_00.txt AC 1164 ms 6840 KB
10_random_01.txt AC 1142 ms 6812 KB
10_random_02.txt AC 1220 ms 6816 KB
10_random_03.txt AC 1079 ms 6816 KB
10_random_04.txt AC 1127 ms 6816 KB
10_random_05.txt AC 1135 ms 6812 KB
10_random_06.txt AC 1161 ms 6744 KB
10_random_07.txt AC 1234 ms 6820 KB
10_random_08.txt AC 1093 ms 6820 KB
10_random_09.txt AC 1113 ms 6816 KB
10_random_10.txt AC 1182 ms 6812 KB
10_random_11.txt AC 1138 ms 6816 KB
10_random_12.txt AC 1180 ms 6816 KB
10_random_13.txt AC 1114 ms 6848 KB
10_random_14.txt AC 1092 ms 6816 KB
10_random_15.txt AC 1227 ms 6816 KB
10_random_16.txt AC 1148 ms 6856 KB
10_random_17.txt AC 1186 ms 6808 KB
10_random_18.txt AC 1152 ms 6864 KB
10_random_19.txt AC 1103 ms 6812 KB
10_random_20.txt AC 1205 ms 6860 KB
10_random_21.txt AC 1099 ms 6796 KB
10_random_22.txt AC 1108 ms 6848 KB
10_random_23.txt AC 1190 ms 6844 KB
10_random_24.txt AC 1192 ms 6864 KB
10_random_25.txt AC 1089 ms 6856 KB
10_random_26.txt AC 1184 ms 6808 KB
10_random_27.txt AC 1106 ms 6868 KB
10_random_28.txt AC 1221 ms 6792 KB
10_random_29.txt AC 1145 ms 6816 KB
22_random_30.txt AC 1185 ms 6812 KB
22_random_31.txt AC 1164 ms 6792 KB
23_coplete_32.txt WA 1027 ms 6816 KB
23_coplete_33.txt WA 1085 ms 6816 KB
24_path_34.txt AC 1215 ms 6720 KB
24_path_35.txt AC 1214 ms 6808 KB
25_tree_36.txt AC 1211 ms 6816 KB
25_tree_37.txt AC 1056 ms 6792 KB
26_noedge_38.txt WA 1095 ms 6816 KB
27_dot_39.txt WA 96 ms 6724 KB