Submission #1275800


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int t;cin>>t;
  for(int i=0;i<t;i++){
      int n;cin>>n;
      VVI v(n,vector<int>(n));
      bool flag=true;
      int dis[n][n];
      for(int j=0;j<n;j++){
          for(int k=0;k<n;k++){
              dis[j][k]=INF;
              if(j==k)dis[j][k]=0;
              cin>>v[j][k];
              if(v[j][k]==-1) continue;
              dis[j][k]=min(dis[j][k],v[j][k]);
          }
      }
      for(int k=0;k<n;k++){
          for(int l=0;l<n;l++){
              for(int m=0;m<n;m++){
                  if(v[l][m]!=-1&&v[l][m]>dis[l][k]+dis[k][m]) flag=false;
              }
          }
      }
      if(flag) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
  }
}

Submission Info

Submission Time
Task C - 最短経路
User zaki_
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1105 Byte
Status WA
Exec Time 4 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 3
WA × 38
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 WA 4 ms 256 KB
10_random_01.txt WA 4 ms 256 KB
10_random_02.txt WA 4 ms 256 KB
10_random_03.txt WA 4 ms 256 KB
10_random_04.txt WA 4 ms 256 KB
10_random_05.txt WA 4 ms 256 KB
10_random_06.txt WA 4 ms 256 KB
10_random_07.txt WA 4 ms 256 KB
10_random_08.txt WA 4 ms 256 KB
10_random_09.txt WA 4 ms 256 KB
10_random_10.txt WA 4 ms 256 KB
10_random_11.txt WA 4 ms 256 KB
10_random_12.txt WA 4 ms 256 KB
10_random_13.txt WA 4 ms 256 KB
10_random_14.txt WA 4 ms 256 KB
10_random_15.txt WA 4 ms 256 KB
10_random_16.txt WA 4 ms 256 KB
10_random_17.txt WA 4 ms 256 KB
10_random_18.txt WA 4 ms 256 KB
10_random_19.txt WA 4 ms 256 KB
10_random_20.txt WA 4 ms 256 KB
10_random_21.txt WA 4 ms 256 KB
10_random_22.txt WA 4 ms 256 KB
10_random_23.txt WA 4 ms 256 KB
10_random_24.txt WA 4 ms 256 KB
10_random_25.txt WA 4 ms 256 KB
10_random_26.txt WA 4 ms 256 KB
10_random_27.txt WA 4 ms 256 KB
10_random_28.txt WA 4 ms 256 KB
10_random_29.txt WA 4 ms 256 KB
22_random_30.txt AC 4 ms 256 KB
22_random_31.txt AC 4 ms 256 KB
23_coplete_32.txt WA 4 ms 256 KB
23_coplete_33.txt WA 4 ms 256 KB
24_path_34.txt WA 4 ms 256 KB
24_path_35.txt WA 4 ms 256 KB
25_tree_36.txt WA 4 ms 256 KB
25_tree_37.txt WA 4 ms 256 KB
26_noedge_38.txt WA 4 ms 256 KB
27_dot_39.txt WA 1 ms 256 KB