Submission #1056678


Source Code Expand

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

#define INF 1e9
#define int long long

signed main(){
	int n, m;
	cin >> n >> m;
	int dist[n][n], mm = m;
	fill(dist[0], dist[n], INF);
	for(int i = 0; i < n; i++) dist[i][i] = 0;
	bool isedge[n][n];
	fill(isedge[0], isedge[n], false);
	while(mm--){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		dist[a][b] = dist[b][a] = c;
		isedge[a][b] = isedge[b][a] = true;
	}
	bool used[n][n];
	fill(used[0], used[n], false);
	for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(dist[i][j] > dist[i][k] + dist[k][j]){
		dist[i][j] = dist[i][k] + dist[k][j];
		used[i][k] = used[k][j] = true;
	}
	int ans = 0;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(isedge[i][j] && !used[i][j]) ans++;
	cout << ans / 2 << endl;
}

Submission Info

Submission Time
Task D - Candidates of No Shortest Paths
User jbyxm
Language C++14 (GCC 5.4.1)
Score 0
Code Size 851 Byte
Status
Exec Time 5 ms
Memory 512 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
All 0 / 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 3 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 512 KB
subtask_1_05.txt 5 ms 384 KB
subtask_1_06.txt 3 ms 256 KB
subtask_1_07.txt 3 ms 256 KB
subtask_1_08.txt 4 ms 384 KB
subtask_1_09.txt 4 ms 384 KB
subtask_1_10.txt 4 ms 384 KB
subtask_1_11.txt 3 ms 256 KB
subtask_1_12.txt 3 ms 256 KB
subtask_1_13.txt 4 ms 384 KB
subtask_1_14.txt 4 ms 384 KB
subtask_1_15.txt 4 ms 384 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 5 ms 384 KB
subtask_1_25.txt 4 ms 256 KB
subtask_1_26.txt 4 ms 256 KB
subtask_1_27.txt 5 ms 512 KB
subtask_1_28.txt 4 ms 384 KB