Submission #532995


Source Code Expand

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int T;
	scanf("%d", &T);
	for(int ii = 0; ii < T; ++ ii) {
		int N;
		scanf("%d", &N);
		vector<vi> a(N, vi(N));
		bool ok = true;
		rep(i, N) rep(j, N) {
			scanf("%d", &a[i][j]);
			if(i == j) ok &= a[i][j] == 0;
			if(a[i][j] == -1)
				a[i][j] = INF;
		}
		rep(k, N) rep(i, N) rep(j, N)
			if(a[i][j] > a[i][k] + a[k][j])
				ok = false;
		puts(ok ? "YES" : "NO");
	}
	return 0;
}

Submission Info

Submission Time
Task C - 最短経路
User anta
Language C++11 (GCC 4.9.2)
Score 100
Code Size 1628 Byte
Status AC
Exec Time 33 ms
Memory 964 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &T);
                 ^
./Main.cpp:43:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
                  ^
./Main.cpp:47:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &a[i][j]);
                         ^

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 41
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 25 ms 920 KB
10_random_00.txt AC 32 ms 920 KB
10_random_01.txt AC 30 ms 796 KB
10_random_02.txt AC 31 ms 924 KB
10_random_03.txt AC 32 ms 916 KB
10_random_04.txt AC 30 ms 808 KB
10_random_05.txt AC 31 ms 792 KB
10_random_06.txt AC 30 ms 920 KB
10_random_07.txt AC 30 ms 796 KB
10_random_08.txt AC 31 ms 800 KB
10_random_09.txt AC 30 ms 908 KB
10_random_10.txt AC 31 ms 928 KB
10_random_11.txt AC 30 ms 924 KB
10_random_12.txt AC 30 ms 912 KB
10_random_13.txt AC 30 ms 924 KB
10_random_14.txt AC 33 ms 924 KB
10_random_15.txt AC 32 ms 912 KB
10_random_16.txt AC 30 ms 920 KB
10_random_17.txt AC 30 ms 912 KB
10_random_18.txt AC 32 ms 920 KB
10_random_19.txt AC 32 ms 920 KB
10_random_20.txt AC 31 ms 924 KB
10_random_21.txt AC 31 ms 932 KB
10_random_22.txt AC 31 ms 928 KB
10_random_23.txt AC 31 ms 924 KB
10_random_24.txt AC 31 ms 928 KB
10_random_25.txt AC 29 ms 928 KB
10_random_26.txt AC 31 ms 932 KB
10_random_27.txt AC 29 ms 924 KB
10_random_28.txt AC 31 ms 928 KB
10_random_29.txt AC 29 ms 928 KB
22_random_30.txt AC 29 ms 924 KB
22_random_31.txt AC 31 ms 928 KB
23_coplete_32.txt AC 32 ms 964 KB
23_coplete_33.txt AC 31 ms 928 KB
24_path_34.txt AC 31 ms 928 KB
24_path_35.txt AC 32 ms 796 KB
25_tree_36.txt AC 31 ms 920 KB
25_tree_37.txt AC 31 ms 932 KB
26_noedge_38.txt AC 28 ms 932 KB
27_dot_39.txt AC 26 ms 924 KB