Language: C++

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

//頂点fromkら頂点へのtoへのコストcostの辺
struct edge { int from, to, cost;};

const int MAX_V = 100;
const int MAX_E = 10000;
const int INF = 9999;

edge es[MAX_E];

int prev[MAX_V];
int d[MAX_V];   //最短距離
 int V, E;       //Vは頂点数、Eは辺の数
int used[MAX_V][MAX_V];

//s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
  for(int i = 0; i < V; i++) d[i] = INF;
  fill(prev, prev + V, -1);
  d[s] = 0;
  while (true) {
    bool update = false;
    for(int i = 0; i < E; i++) {
      edge e = es[i];
      if (d[e.from] != INF &&  d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
        prev[e.to] = prev[e.from];
      }
    }
    if(!update) break;
  }
}

vector<int> get_path(int t) {
  vector<int> path;
  for(; t != -1 ; t = prev[t]) path.push_back(t);
  reverse(path.begin(), path.end());
  return path;
}

int main() {
  int ans = 0;
  cin >> V >> E;

  for(int i = 0; i < E; i++) {
    cin >> es[i].to >> es[i].from >> es[i].cost;
  }

  for(int i = 0; i < V; i++) {
    shortest_path(i);
    for(int j = 1; j < V; j++) {
      vector<int> path = get_path(j);
      for(int k = 0; k < path.size()-1; k++) {
        used[path[k]][path[k+1]] = 1;
      }
    }
  }

  for(int i = 0; i < E; i++) {
    if(!used[es[i].to][es[i].from]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'void shortest_path(int)':
a.cc:24:8: error: reference to 'prev' is ambiguous
   24 |   fill(prev, prev + V, -1);
      |        ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:16:5: note:                 'int prev [100]'
   16 | int prev[MAX_V];
      |     ^~~~
a.cc:24:14: error: reference to 'prev' is ambiguous
   24 |   fill(prev, prev + V, -1);
      |              ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:16:5: note:                 'int prev [100]'
   16 | int prev[MAX_V];
      |     ^~~~
a.cc:33:9: error: reference to 'prev' is ambiguous
   33 |         prev[e.to] = prev[e.from];
      |         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:16:5: note:                 'int prev [100]'
   16 | int prev[MAX_V];
      |     ^~~~
a.cc:33:22: error: reference to 'prev' is ambiguous
   33 |         prev[e.to] = prev[e.from];
      |                      ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:16:5: note:                 'int prev [100]'
   16 | int prev[MAX_V];
      |     ^~~~
a.cc: In function 'std::vector<int> get_path(int)':
a.cc:42:23: error: reference to 'prev' is ambiguous
   42 |   for(; t != -1 ; t = prev[t]) path.push_back(t);
      |                       ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:16:5: note:                 'int prev [100]'
   16 | int prev[MAX_V];
      |     ^~~~