Submission #1780658


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define loINF (long)10000000000
#define shINF (short)10000
#define MIN(a, b) ((a) < (b) ? (a) : (b))

/*global*/
long dist[310][310];	//頂点間の重みを格納する。
short V;			//頂点数

short Warshall_Floyd (void){
	//返り値が-1なら負の閉路あり。0なら正常終了
	short i,j,k;

	REP(k,V){
		REP(i,V){
			REP(j,V){
				dist[i][j] = MIN(dist[i][j],dist[i][k] + dist[k][j]);

				#ifdef DEBUG
				printf("dist[%d][%d] ==> %ld\n",i,j,dist[i][j]);
				#endif //DEBUG

				if (dist[i][j] < 0){
					return (-1);
				}
			}
		}
	}
	return 0;
}

int main (void){
	short i,j;
	long E;
	short edge1,edge2;
	long weight,ans;
	long tmp;

	scanf("%hd",&V);	//頂点数の入力
	scanf("%ld",&E);	//

	/*初期化*/
	REP(i,V){
		REP(j,V){
			dist[i][j] = loINF;
		}
		dist[i][i] = 0;
	}
	/*辺の入力*/
	REP(i,E){
		scanf("%hd%hd%ld",&edge1,&edge2,&weight);
		dist[edge1-1][edge2-1] = weight;
		dist[edge2-1][edge1-1] = weight;
	}


	#ifdef DEBUG
		printf("ワーシャルフロイド前\n");
		REP(i,V) 
			REP(j,V) 
				printf("dist[%d][%d] ==> %ld\n",i,j,dist[i][j]);
	#endif

	j = Warshall_Floyd();

	ans = loINF;
	tmp = 0;

	REP(i,V){
		REP(j,V){
			if (tmp < dist[i][j]) tmp = dist[i][j];
		}
		if (tmp < ans) ans = tmp;
		tmp = 0;
	}

	printf("%ld\n",ans);

	return 0;
}

Submission Info

Submission Time
Task D - バスと避けられない運命
User banboooo044
Language C (GCC 5.4.1)
Score 100
Code Size 1501 Byte
Status AC
Exec Time 48 ms
Memory 896 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:42:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%hd",&V); //頂点数の入力
  ^
./Main.c:43:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%ld",&E); //
  ^
./Main.c:54:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%hd%hd%ld",&edge1,&edge2,&weight);
   ^

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 39
Set Name Test Cases
All sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt
Case Name Status Exec Time Memory
sample_01.txt AC 0 ms 128 KB
sample_02.txt AC 0 ms 128 KB
sample_03.txt AC 0 ms 128 KB
test_01.txt AC 0 ms 128 KB
test_02.txt AC 43 ms 896 KB
test_03.txt AC 48 ms 896 KB
test_04.txt AC 14 ms 640 KB
test_05.txt AC 16 ms 640 KB
test_06.txt AC 2 ms 384 KB
test_07.txt AC 36 ms 768 KB
test_08.txt AC 1 ms 256 KB
test_09.txt AC 11 ms 640 KB
test_10.txt AC 2 ms 384 KB
test_11.txt AC 2 ms 384 KB
test_12.txt AC 20 ms 768 KB
test_13.txt AC 2 ms 384 KB
test_14.txt AC 3 ms 384 KB
test_15.txt AC 33 ms 768 KB
test_16.txt AC 3 ms 384 KB
test_17.txt AC 13 ms 640 KB
test_18.txt AC 18 ms 768 KB
test_19.txt AC 4 ms 384 KB
test_20.txt AC 3 ms 384 KB
test_21.txt AC 0 ms 128 KB
test_22.txt AC 7 ms 512 KB
test_23.txt AC 1 ms 256 KB
test_24.txt AC 38 ms 896 KB
test_25.txt AC 38 ms 896 KB
test_26.txt AC 9 ms 640 KB
test_27.txt AC 12 ms 640 KB
test_28.txt AC 38 ms 896 KB
test_29.txt AC 38 ms 896 KB
test_30.txt AC 2 ms 384 KB
test_31.txt AC 1 ms 256 KB
test_32.txt AC 38 ms 896 KB
test_33.txt AC 38 ms 896 KB
test_34.txt AC 1 ms 384 KB
test_35.txt AC 7 ms 512 KB
test_36.txt AC 38 ms 896 KB