Submission #1692336


Source Code Expand

#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int main(){
    int t;
    cin >> t;
    rep(va, t){
        int n;
        cin >> n;
        vvi G(n, vi(n));
        rep(i, n)rep(j, n){
            cin >> G[i][j];
            if(G[i][j] == -1)
                G[i][j] = inf;
            if(G[i][j] && i == j){
                cout << "NO" << endl;
                goto matoba;
            }
        }
        rep(k, n)rep(i, n)rep(j, n)
            if(G[i][j] > G[i][k] + G[k][j]){
                cout << "NO" << endl;
                goto matoba;
            }
        cout << "YES" << endl;
        matoba:;
    }
}

Submission Info

Submission Time
Task C - 最短経路
User Masumi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 976 Byte
Status RE
Exec Time 1419 ms
Memory 369160 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 16
RE × 25
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 1 ms 256 KB
10_random_00.txt RE 99 ms 384 KB
10_random_01.txt AC 7 ms 256 KB
10_random_02.txt AC 6 ms 256 KB
10_random_03.txt RE 97 ms 256 KB
10_random_04.txt AC 7 ms 256 KB
10_random_05.txt AC 7 ms 256 KB
10_random_06.txt RE 96 ms 256 KB
10_random_07.txt RE 134 ms 79360 KB
10_random_08.txt RE 97 ms 256 KB
10_random_09.txt RE 100 ms 256 KB
10_random_10.txt AC 7 ms 256 KB
10_random_11.txt RE 257 ms 360192 KB
10_random_12.txt RE 98 ms 256 KB
10_random_13.txt AC 7 ms 256 KB
10_random_14.txt RE 100 ms 256 KB
10_random_15.txt RE 1419 ms 369160 KB
10_random_16.txt AC 7 ms 256 KB
10_random_17.txt RE 98 ms 256 KB
10_random_18.txt RE 98 ms 256 KB
10_random_19.txt AC 7 ms 256 KB
10_random_20.txt AC 7 ms 256 KB
10_random_21.txt RE 101 ms 256 KB
10_random_22.txt RE 99 ms 256 KB
10_random_23.txt RE 101 ms 256 KB
10_random_24.txt RE 98 ms 256 KB
10_random_25.txt RE 641 ms 355184 KB
10_random_26.txt RE 100 ms 256 KB
10_random_27.txt RE 332 ms 310912 KB
10_random_28.txt RE 211 ms 246272 KB
10_random_29.txt AC 7 ms 256 KB
22_random_30.txt RE 96 ms 256 KB
22_random_31.txt RE 96 ms 384 KB
23_coplete_32.txt AC 8 ms 256 KB
23_coplete_33.txt AC 8 ms 256 KB
24_path_34.txt RE 98 ms 3072 KB
24_path_35.txt AC 7 ms 256 KB
25_tree_36.txt RE 100 ms 256 KB
25_tree_37.txt AC 7 ms 256 KB
26_noedge_38.txt RE 97 ms 256 KB
27_dot_39.txt AC 1 ms 256 KB