Submission #2864091


Source Code Expand

Copy
#include <iostream>
#include <vector>
using namespace std;
const int INF = (1e9);
int main(){
  int N, M;
  cin >> N >> M;
  vector< vector<int> > G(N, vector<int>(N,INF));
  vector<int> A(N), B(N), C(N);
  for(int i = 0; i < M; ++i){
    int a, b, c;
    cin >> a >> b >> c;
    --a;--b;
    G[a][b] = c;
    G[b][a] = c;
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }
  for(int k = 0; k < N; ++k){
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < M; ++i){
    if(G[A[i]][B[i]] != C[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Candidates of No Shortest Paths
User TAB
Language C++14 (GCC 5.4.1)
Score 0
Code Size 690 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
All 0 / 400 sample_01.txt, sample_02.txt, 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 1 ms 256 KB
sample_02.txt 1 ms 256 KB
subtask_1_01.txt 1 ms 256 KB
subtask_1_02.txt 1 ms 256 KB
subtask_1_03.txt
subtask_1_04.txt 3 ms 256 KB
subtask_1_05.txt
subtask_1_06.txt
subtask_1_07.txt 2 ms 256 KB
subtask_1_08.txt
subtask_1_09.txt 3 ms 256 KB
subtask_1_10.txt
subtask_1_11.txt
subtask_1_12.txt
subtask_1_13.txt 3 ms 256 KB
subtask_1_14.txt
subtask_1_15.txt 3 ms 256 KB
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