Language: C++


using namespace std;
using ll = long long;
#define rep(i, j) for(int i = 0; i < (int)(j); i++)
constexpr int INF = 1 << 28;
constexpr ll INFL = 1LL << 60;
struct State{
    int index;
    ll cost;
    State(int i, ll c):index(i), cost(c) {}
    bool operator > (const State &r) const { return cost < r.cost; }
};
//
//
vector<ll> dijkstra(const EdgeList &G, int start) {
    priority_queue<State, vector<State>, greater<State>> que;
    vector<ll> dist(G.size(), INFL);
    que.emplace(start, 0);
    dist[start] = 0;
    while(not que.empty()){
        State now = que.top(); que.pop();
        for(Edge e : G[now.index]){
            if(dist[e.to] > now.cost + e.cost){
                State nxt = State(e.to, now.cost + e.cost);
                dist[e.to] = nxt.cost;                
                que.push(nxt);
            }
        }
    }
    return dist;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
int main() {
    int N, M, R; cin >> N >> M >> R;
    EdgeList E(N);
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        E[a].push_back(Edge(b, c));
        E[b].push_back(Edge(a, c));
    }
    auto dist = dijkstra(E, R);
    for(ll d : dist) cout << (d < INFL ? to_string(d) : "INF") << endl;
    return 0;
}

Compiler output:
a.cc:15:1: error: 'vector' does not name a type
   15 | vector<ll> dijkstra(const EdgeList &G, int start) {
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:34:18: error: 'cin' was not declared in this scope
   34 |     int N, M, R; cin >> N >> M >> R;
      |                  ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:35:5: error: 'EdgeList' was not declared in this scope
   35 |     EdgeList E(N);
      |     ^~~~~~~~
a.cc:38:9: error: 'E' was not declared in this scope
   38 |         E[a].push_back(Edge(b, c));
      |         ^
a.cc:38:24: error: 'Edge' was not declared in this scope
   38 |         E[a].push_back(Edge(b, c));
      |                        ^~~~
a.cc:41:26: error: 'E' was not declared in this scope
   41 |     auto dist = dijkstra(E, R);
      |                          ^
a.cc:41:17: error: 'dijkstra' was not declared in this scope
   41 |     auto dist = dijkstra(E, R);
      |                 ^~~~~~~~
a.cc:42:22: error: 'cout' was not declared in this scope
   42 |     for(ll d : dist) cout << (d < INFL ? to_string(d) : "INF") << endl;
      |                      ^~~~
a.cc:42:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:42:42: error: 'to_string' was not declared in this scope
   42 |     for(ll d : dist) cout << (d < INFL ? to_string(d) : "INF") << endl;
      |                                          ^~~~~~~~~
a.cc:1:1: note: 'std::to_string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | 
a.cc:42:67: error: 'endl' was not declared in this scope
   42 |     for(ll d : dist) cout << (d < INFL ? to_string(d) : "INF") << endl;
      |                                                                   ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 |