Language: C++

#include <queue>
#include <stdint.h>
#include <vector>

typedef void (*single_source_shortest_path_callback_t)(int32_t index, int32_t weight);

#define GRAPH_MAX_SIZE 10000
extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
                                        single_source_shortest_path_callback_t callback);

enum color_t { WHITE, GRAY, BLACK };

static int32_t weights[GRAPH_MAX_SIZE];
static color_t colors[GRAPH_MAX_SIZE];

bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
{
  if ((graph == nullptr) || (size == 0)) return false;

  int32_t i;
  for (i = 0; i < GRAPH_MAX_SIZE; i++) {
    weights[i] = INT32_MAX;
    colors[i] = WHITE;
  }

  weights[0] = 0;
  priority_queue<pair<int32_t, int32_t>> que;
  que.push(make_pair(-1 * weights[0], 0));

  while (!que.empty()) {
    pair<int, int> top = que.top();
    que.pop();
    int32_t top_index = top.second;
    int32_t top_weights = (-1) * top.first;
    if (top_weights > weights[top_index]) continue;

    callback(top_index, top_weights);
    colors[top_index] = BLACK;

    vector<pair<int32_t, int32_t>> vertex = graph[top_index];
    for (auto connect_to = vertex.begin(); connect_to != vertex.end(); connect_to++) {
      int32_t index = (*connect_to).first;
      if (colors[index] != BLACK) {
        int32_t new_weight = weights[top_index] + (*connect_to).second;

        if (new_weight < weights[index]) {
          weights[index] = new_weight;
          colors[index] = GRAY;
          que.push(make_pair(-1 * weights[index], index));
        }
      }
    }
  }
  return true;
}

#if !defined(TEST)
static vector<pair<int32_t, int32_t>> graph[GRAPH_MAX_SIZE];
static int32_t routes[GRAPH_MAX_SIZE];

void callback(int32_t index, int32_t weight)
{
  routes[index] = weight;
}

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);

  uint32_t i;
  for (i = 0; i < num; i++) {
    int32_t index, len;
    scanf("%d", &index);
    scanf("%d", &len);
    uint32_t j;
    for (j = 0; j < len; j++) {
      int32_t k, v;
      scanf("%d %d", &k, &v);
      graph[i].push_back(make_pair(k, v));
    }
  }
  single_source_shortest_path(graph, num, callback);

  for (i = 0; i < num; i++) {
    printf("%d %d\n", i, routes[i]);
  }

  return 0;
}
#endif

Compiler output:
a.cc:8:13: warning: 'single_source_shortest_path' initialized and declared 'extern'
    8 | extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:8:41: error: 'vector' was not declared in this scope
    8 | extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
      |                                         ^~~~~~
a.cc:8:41: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/queue:63,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:8:48: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    8 | extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
      |                                                ^~~~
      |                                                std::pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/queue:62:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:8:60: error: expected primary-expression before ',' token
    8 | extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
      |                                                            ^
a.cc:8:69: error: expected primary-expression before '>>' token
    8 | extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
      |                                                                     ^~
a.cc:8:73: error: 'graph' was not declared in this scope
    8 | extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
      |                                                                         ^~~~~
a.cc:8:87: error: expected primary-expression before 'size'
    8 | extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
      |                                                                                       ^~~~
a.cc:9:80: error: expected primary-expression before 'callback'
    9 |                                         single_source_shortest_path_callback_t callback);
      |                                                                                ^~~~~~~~
a.cc:9:88: error: expression list treated as compound expression in initializer [-fpermissive]
    9 |                                         single_source_shortest_path_callback_t callback);
      |                                                                                        ^
a.cc:16:6: error: redefinition of 'bool single_source_shortest_path'
   16 | bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:8:13: note: 'bool single_source_shortest_path' previously defined here
    8 | extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:16:34: error: 'vector' was not declared in this scope
   16 | bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
      |                                  ^~~~~~
a.cc:16:34: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:16:41: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   16 | bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
      |                                         ^~~~
      |                                         std::pair
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:16:53: error: expected primary-expression before ',' token
   16 | bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
      |                                                     ^
a.cc:16:62: error: expected primary-expression before '>>' token
   16 | bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
      |                                                              ^~
a.cc:16:66: error: 'graph' was not declared in this scope
   16 | bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
      |                                                                  ^~~~~
a.cc:16:80: error: expected primary-expression before 'size'
   16 | bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
      |                                                                                ^~~~
a.cc:16:125: error: expected primary-expression before 'callback'
   16 | bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
      |                                                                                                                             ^~~~~~~~
a.cc:58:8: error: 'vector' does not name a type
   58 | static vector<pair<int32_t, int32_t>> graph[GRAPH_MAX_SIZE];
      |        ^~~~~~
a.cc: In function 'int32_t main()':
a.cc:69:3: error: 'scanf' was not declared in this scope
   69 |   scanf("%d", &num);
      |   ^~~~~
a.cc:80:7: error: 'graph' was not declared in this scope
   80 |       graph[i].push_back(make_pair(k, v));
      |       ^~~~~
a.cc:80:26: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   80 |       graph[i].push_back(make_pair(k, v));
      |                          ^~~~~~~~~
      |                          std::make_pair
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:83:31: error: 'graph' was not declared in this scope
   83 |   single_source_shortest_path(graph, num, callback);
      |                               ^~~~~
a.cc:83:30: error: 'single_source_shortest_path' cannot be used as a function
   83 |   single_source_shortest_path(graph, num, callback);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:86:5: error: 'printf' was not declared in this scope
   86 |     printf("%d %d\n", i, routes[i]);
      |     ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include <stdint.h>
  +++ |+#include <cstdio>
    3 | #include <vector>