Submission #1057821


Source Code Expand

Copy
#include <iostream>
#include <algorithm>
using namespace std;

#define INF 1e9

int main(){
	int n, m;
	cin >> n >> m;
	int dist[n][n];
	fill(dist[0], dist[n], INF);
	for(int i = 0; i < n; i++) dist[i][i] = 0;
	while(m--){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		dist[a][b] = dist[b][a] = c;
	}
	int score[n][n];
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) score[i][j] = dist[i][j];
	for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) score[i][j] = min(score[i][j], score[i][k] + score[k][j]);
	int ans = 0;
	for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) if(dist[i][j] != INF && dist[i][j] > score[i][j]) ans++;
	cout << ans << endl;
}

Submission Info

Submission Time
Task D - Candidates of No Shortest Paths
User jbyxm
Language C++14 (GCC 5.4.1)
Score 400
Code Size 723 Byte
Status
Exec Time 4 ms
Memory 256 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
All 400 / 400 subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt
Case Name Status Exec Time Memory
sample_01.txt 2 ms 256 KB
sample_02.txt 3 ms 256 KB
subtask_1_01.txt 3 ms 256 KB
subtask_1_02.txt 3 ms 256 KB
subtask_1_03.txt 3 ms 256 KB
subtask_1_04.txt 4 ms 256 KB
subtask_1_05.txt 4 ms 256 KB
subtask_1_06.txt 3 ms 256 KB
subtask_1_07.txt 3 ms 256 KB
subtask_1_08.txt 4 ms 256 KB
subtask_1_09.txt 4 ms 256 KB
subtask_1_10.txt 4 ms 256 KB
subtask_1_11.txt 3 ms 256 KB
subtask_1_12.txt 3 ms 256 KB
subtask_1_13.txt 4 ms 256 KB
subtask_1_14.txt 4 ms 256 KB
subtask_1_15.txt 4 ms 256 KB
subtask_1_16.txt 3 ms 256 KB
subtask_1_17.txt 3 ms 256 KB
subtask_1_18.txt 3 ms 256 KB
subtask_1_19.txt 3 ms 256 KB
subtask_1_20.txt 3 ms 256 KB
subtask_1_21.txt 3 ms 256 KB
subtask_1_22.txt 3 ms 256 KB
subtask_1_23.txt 3 ms 256 KB
subtask_1_24.txt 4 ms 256 KB
subtask_1_25.txt 3 ms 256 KB
subtask_1_26.txt 3 ms 256 KB
subtask_1_27.txt 4 ms 256 KB
subtask_1_28.txt 4 ms 256 KB