Language: C++

#include <iostream>
#include <queue>
#include <vector>

using namespace std;

template <typename T> struct Edge {
  T dst, cost;
  Edge(int dst, int cost) : dst(dst), cost(cost) {}
  bool operator>(const Edge<T> &rhs) const { return cost > rhs.cost; }
};

const int INF = 1 << 30;

template <typename T> vector<T> dijkstra(vector< vector< Edge< T > > > tree, T src) {
  size_t V = tree.size();
  vector<T> dist = vector<T>(V, INF);
  priority_queue< Edge< T >, vector< Edge< T > >, greater< Edge< T > > > queue;

  dist[src] = 0;
  queue.push(Edge<T>(src, 0));
  while (!queue.empty()) {
    Edge<T> t = queue.top();
    queue.pop();
    int v = t.dst, cost = t.cost;

    if (dist[v] < cost) {
      continue;
    }
    for (size_t i = 0; i < V; i++) {
      Edge<T> e = tree[v][i];
      if (dist[v] + e.cost < dist[e.dst]) {
        dist[e.dst] = dist[v] + e.cost;
        queue.push(Edge<T>(e.dst, dist[e.dst]));
      }
    }
  }

  return dist;
}

int main(int argc, char const *argv[]) {
  int V, E, r;
  cin >> V >> E >> r;
  vector<vector<int>> dp = vector< vector< int > >(V, vector<int>(V, INF));

  for (size_t i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    dp[s][t] = d;
  }

  vector< vector< Edge< int > > > tree = vector< vector< Edge< int> > >(V);

  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      tree[i].push_back(Edge<int>(j, dp[i][j]));
    }
  }

  vector<int> ret = dijkstra(tree, r);
  for (size_t i = 0; i < V; i++) {
    int d = ret[i];
    if (d >= INF) {
      cout << "INF" << endl;
    } else {
      cout << d << endl;
    }
  }

  return 0;
}
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

template <typename T> struct Edge {
  T dst, cost;
  Edge(int dst, int cost) : dst(dst), cost(cost) {}
  bool operator>(const Edge<T> &rhs) const { return cost > rhs.cost; }
};

const int INF = 1 << 30;

template <typename T> vector<T> dijkstra(vector<vector<Edge<T>>> tree, T src) {
  size_t V = tree.size();
  vector<T> dist = vector<T>(V, INF);
  priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> queue;

  dist[src] = 0;
  queue.push(Edge<T>(src, 0));
  while (!queue.empty()) {
    Edge<T> t = queue.top();
    queue.pop();
    int v = t.dst, cost = t.cost;

    if (dist[v] < cost) {
      continue;
    }
    for (size_t i = 0; i < V; i++) {
      Edge<T> e = tree[v][i];
      if (dist[v] + e.cost < dist[e.dst]) {
        dist[e.dst] = dist[v] + e.cost;
        queue.push(Edge<T>(e.dst, dist[e.dst]));
      }
    }
  }

  return dist;
}

int main(int argc, char const *argv[]) {
  int V, E, r;
  cin >> V >> E >> r;
  vector<vector<int>> dp = vector<vector<int>>(V, vector<int>(V, INF));

  for (size_t i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    dp[s][t] = d;
  }

  vector<vector<Edge<int>>> tree = vector<vector<Edge<int>>>(V);

  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      tree[i].push_back(Edge<int>(j, dp[i][j]));
    }
  }

  vector<int> ret = dijkstra(tree, r);
  for (size_t i = 0; i < V; i++) {
    int d = ret[i];
    if (d >= INF) {
      cout << "INF" << endl;
    } else {
      cout << d << endl;
    }
  }

  return 0;
}



Compiler output:
a.cc:79:30: error: redefinition of 'struct Edge<T>'
   79 | template <typename T> struct Edge {
      |                              ^~~~
a.cc:7:30: note: previous definition of 'struct Edge<T>'
    7 | template <typename T> struct Edge {
      |                              ^~~~
a.cc:85:11: error: redefinition of 'const int INF'
   85 | const int INF = 1 << 30;
      |           ^~~
a.cc:13:11: note: 'const int INF' previously defined here
   13 | const int INF = 1 << 30;
      |           ^~~
a.cc:87:33: error: redefinition of 'template<class T> std::vector<_Tp> dijkstra(std::vector<std::vector<Edge<T> > >, T)'
   87 | template <typename T> vector<T> dijkstra(vector<vector<Edge<T>>> tree, T src) {
      |                                 ^~~~~~~~
a.cc:15:33: note: 'template<class T> std::vector<_Tp> dijkstra(std::vector<std::vector<Edge<T> > >, T)' previously declared here
   15 | template <typename T> vector<T> dijkstra(vector< vector< Edge< T > > > tree, T src) {
      |                                 ^~~~~~~~
a.cc:114:5: error: redefinition of 'int main(int, const char**)'
  114 | int main(int argc, char const *argv[]) {
      |     ^~~~
a.cc:42:5: note: 'int main(int, const char**)' previously defined here
   42 | int main(int argc, char const *argv[]) {
      |     ^~~~