Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <string>

// 1.7E +/- 308
//const static double INF = 1.7e+308;
// 4,294,967,295
const static unsigned int INF = 4294967294;

class Graph {
public:
	// エッジ
	struct Edge {
		// 接続先のノード番号
		int node;
		// 移動コスト
		int cost;
		// コンストラクタ
		Edge(const int node, const int cost) : node(node), cost(cost) {	}
	};
	// ノード
	struct Node {
		// エッジ
		std::vector<Edge> edges_;
	};

	// コンストラクタ
	Graph(std::istream& in) {
		// 総ノード数の読み込み
		int n;
		in >> n;
		// ノード用配列を初期化
		nodes_.resize(n);

		// 総エッジ数の抽出
		int e;
		in >> e;

		// 開始ノードの抽出
		int start;
		in >> start;
		start_ = start;

		// 1
		// エッジデータの読み込み
		for (int i = 0; i != e; ++i) {
			// 始点・終点のノードの番号を読み込む
			int s, t, c;
			// s 始点ノード, t 近隣ノード, c コスト
			in >> s >> t >> c;
			// ノードに近隣ノードの番号を登録
			nodes_[s].edges_.emplace_back(t, c);
		}
	}

	// ノードを取得
	const Node& operator[](int index) const { return nodes_[index]; }
	// ノード数を取得
	std::size_t node_count() const { return nodes_.size(); }
	// 開始ノードの取得
	int start_node() const { return start_; }

private:
	// ノード用配列
	std::vector<Node> nodes_;
	// 開始ノード
	int start_;
};

class PathFinder {
	// 距離とノード番号のペア
	using dist_node = std::pair<unsigned __int64, int>;

public:
	// パス検索
	static std::vector<std::string> find_path(const Graph& graph) {
		// 初期値を最大値にする
		// 経路情報
		// 始めに個数と番号を指定して作成する
		// { 合計コスト, 親の番号 }
		std::vector<dist_node> dist_nodes(graph.node_count(), { INF, -1 });
		// プライオリティキュー
		// 合計コストが少ないパスを取得する greater<>
		std::priority_queue<dist_node, std::vector<dist_node>, std::greater<dist_node>> queue;
		// 開始ノードをキューに登録
		dist_nodes[graph.start_node()] = { 0, -1 };
		queue.push({ 0, graph.start_node() });
		// キューにデータがあるか？
		while (!queue.empty()) {
			// 先頭ノードをキューから取り出す
			const auto front = queue.top();
			// pop でデータを捨てる
			queue.pop();
			const auto front_g = front.first;
			const auto front_node = front.second;

			// キュー内のデータよりも経路情報の合計距離が小さいか？
			// キュー内のデータは最短距離ではないので無視
			// 情報を毎回更新する
			if (dist_nodes[front_node].first < front_g) continue;
			// 近隣ノードを取得
			// for (const auto& node : graph[front_node].nodes_) 
			for (const auto& edge : graph[front_node].edges_) {
				const auto g = dist_nodes[front_node].first + edge.cost;
				// 親ノードまでのコストの合計値と比較して、値が小さければ更新する
				if (dist_nodes[edge.node].first > g) {
					// 経路情報を保存
					dist_nodes[edge.node] = { g, front_node };
					// キューに登録
					queue.push({ g, edge.node });
				}
			}
		}
		// 経路が見つからない場合でも検索していたパスを返す
		return create_cost(dist_nodes);
	}

private:
	// パスの作成
	static std::vector<std::string> create_path(const std::vector<dist_node>& dist_nodes, int end) {
		std::vector<std::string> path;
		for (int node = end; node != -1; node = dist_nodes[node].second) {
			path.push_back(std::to_string(node));
		}

		return path;
	}

	// コスト一覧の生成
	static std::vector<std::string> create_cost(const std::vector<dist_node>& dist_nodes) {
		std::vector<std::string> path;
		for (int i = 0; i != dist_nodes.size(); ++i) {
			std::string cost = std::to_string((int)dist_nodes[i].first);
			//auto inf = std::numeric_limits<float>::max();
			// 無限値の場合は、INFを表示する
			if (dist_nodes[i].first == INF) cost = "INF";
			path.push_back(cost);
		}

		return path;
	}
};

int main() {
	Graph graph(std::cin);
	auto path = PathFinder::find_path(graph);
	// 経路パスの表示(逆順)
	for (auto node_id : path) {
		std::cout << node_id << std::endl;
	}

	return 0;
}


Compiler output:
a.cc:74:58: error: wrong number of template arguments (1, should be 2)
   74 |         using dist_node = std::pair<unsigned __int64, int>;
      |                                                          ^
In file included from /usr/include/c++/14/string:48,
                 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.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc:122:71: error: 'dist_node' was not declared in this scope
  122 |         static std::vector<std::string> create_path(const std::vector<dist_node>& dist_nodes, int end) {
      |                                                                       ^~~~~~~~~
a.cc:122:80: error: template argument 1 is invalid
  122 |         static std::vector<std::string> create_path(const std::vector<dist_node>& dist_nodes, int end) {
      |                                                                                ^
a.cc:122:80: error: template argument 2 is invalid
a.cc:132:71: error: 'dist_node' was not declared in this scope
  132 |         static std::vector<std::string> create_cost(const std::vector<dist_node>& dist_nodes) {
      |                                                                       ^~~~~~~~~
a.cc:132:80: error: template argument 1 is invalid
  132 |         static std::vector<std::string> create_cost(const std::vector<dist_node>& dist_nodes) {
      |                                                                                ^
a.cc:132:80: error: template argument 2 is invalid
a.cc: In static member function 'static std::vector<std::__cxx11::basic_string<char> > PathFinder::find_path(const Graph&)':
a.cc:83:29: error: 'dist_node' was not declared in this scope
   83 |                 std::vector<dist_node> dist_nodes(graph.node_count(), { INF, -1 });
      |                             ^~~~~~~~~
a.cc:83:38: error: template argument 1 is invalid
   83 |                 std::vector<dist_node> dist_nodes(graph.node_count(), { INF, -1 });
      |                                      ^
a.cc:83:38: error: template argument 2 is invalid
a.cc:83:82: error: expression list treated as compound expression in initializer [-fpermissive]
   83 |                 std::vector<dist_node> dist_nodes(graph.node_count(), { INF, -1 });
      |                                                                                  ^
a.cc:83:82: error: cannot convert '<brace-enclosed initializer list>' to 'int' in initialization
a.cc:86:69: error: template argument 2 is invalid
   86 |                 std::priority_queue<dist_node, std::vector<dist_node>, std::greater<dist_node>> queue;
      |                                                                     ^
a.cc:86:94: error: template argument 2 is invalid
   86 |                 std::priority_queue<dist_node, std::vector<dist_node>, std::greater<dist_node>> queue;
      |                                                                                              ^~
a.cc:86:94: error: template argument 3 is invalid
a.cc:88:27: error: invalid types 'int[int]' for array subscript
   88 |                 dist_nodes[graph.start_node()] = { 0, -1 };
      |                           ^
a.cc:89:23: error: request for member 'push' in 'queue', which is of non-class type 'int'
   89 |                 queue.push({ 0, graph.start_node() });
      |                       ^~~~
a.cc:91:31: error: request for member 'empty' in 'queue', which is of non-class type 'int'
   91 |                 while (!queue.empty()) {
      |                               ^~~~~
a.cc:93:50: error: request for member 'top' in 'queue', which is of non-class type 'int'
   93 |                         const auto front = queue.top();
      |                                                  ^~~
a.cc:95:31: error: request for member 'pop' in 'queue', which is of non-class type 'int'
   95 |                         queue.pop();
      |                               ^~~
a.cc:112:47: error: request for member 'push' in 'queue', which is of non-class type 'int'
  112 |                                         queue.push({ g, edge.node });
      |                                               ^~~~
a.cc: In static member function 'static std::vector<std::__cxx11::basic_string<char> > PathFinder::create_path(const int&, int)':
a.cc:124:67: error: invalid types 'const int[int]' for array subscript
  124 |                 for (int node = end; node != -1; node = dist_nodes[node].second) {
      |                                                                   ^
a.cc: In static member function 'static std::vector<std::__cxx11::basic_string<char> > PathFinder::create_cost(const int&)':
a.cc:134:49: error: request for member 'size' in 'dist_nodes', which is of non-class type 'const int'
  134 |                 for (int i = 0; i != dist_nodes.size(); ++i) {
      |                                                 ^~~~
a.cc:135:74: error: invalid types 'const int[int]' for array subscript
  135 |                         std::string cost = std::to_string((int)dist_nodes[i].first);
      |                                                                          ^
a.cc:138:39: error: invalid types 'const int[int]' for array subscript
  138 |                         if (dist_nodes[i].first == INF) cost = "INF";
      |                                       ^