Submission #3587617

Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int memo[105][105] = {0};
vector<pair<int, int>> edge[105];
int n, m;

int solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) memo[i][j] = 100000000;
  for(int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    edge[a].push_back(make_pair(b, c));
    memo[a][b] = memo[b][a] = c;
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        memo[i][j] =
            min(memo[i][j], memo[i][k] + memo[k][j]);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < edge[i].size(); ++j)
      if(memo[i][edge[i][j].first] < edge[i][j].second)
        ++ans;
  return ans;
}

Submission Info

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

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
All 400 / 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 2 ms 256 KB
subtask_1_04.txt 2 ms 256 KB
subtask_1_05.txt 3 ms 256 KB
subtask_1_06.txt 1 ms 256 KB
subtask_1_07.txt 2 ms 256 KB
subtask_1_08.txt 2 ms 256 KB
subtask_1_09.txt 2 ms 256 KB
subtask_1_10.txt 3 ms 256 KB
subtask_1_11.txt 1 ms 256 KB
subtask_1_12.txt 2 ms 256 KB
subtask_1_13.txt 2 ms 256 KB
subtask_1_14.txt 3 ms 256 KB
subtask_1_15.txt 2 ms 256 KB
subtask_1_16.txt 1 ms 256 KB
subtask_1_17.txt 1 ms 256 KB
subtask_1_18.txt 2 ms 256 KB
subtask_1_19.txt 2 ms 256 KB
subtask_1_20.txt 1 ms 256 KB
subtask_1_21.txt 1 ms 256 KB
subtask_1_22.txt 2 ms 256 KB
subtask_1_23.txt 2 ms 256 KB
subtask_1_24.txt 3 ms 256 KB
subtask_1_25.txt 2 ms 256 KB
subtask_1_26.txt 2 ms 256 KB
subtask_1_27.txt 3 ms 256 KB
subtask_1_28.txt 3 ms 256 KB