This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub ruthen71/rcpl
#include "graph/get_edges.hpp"
#pragma once #include "graph/graph_template.hpp" template <class T> Edges<T> get_edges(Graph<T> &G) { int N = (int)G.size(), M = 0; for (int i = 0; i < N; i++) { for (auto &&e : G[i]) { M = std::max(M, e.id + 1); } } Edges<T> es(M); for (int i = N - 1; i >= 0; i--) { for (auto &&e : G[i]) { es[e.id] = e; } } return es; }
#line 2 "graph/get_edges.hpp" #line 2 "graph/graph_template.hpp" #include <vector> template <class T> struct Edge { int from, to; T cost; int id; Edge() = default; Edge(int from, int to, T cost = 1, int id = -1) : from(from), to(to), cost(cost), id(id) {} friend std::ostream &operator<<(std::ostream &os, const Edge<T> &e) { // output format: "{ id : from -> to, cost }" return os << "{ " << e.id << " : " << e.from << " -> " << e.to << ", " << e.cost << " }"; } }; template <class T> using Edges = std::vector<Edge<T>>; template <class T> using Graph = std::vector<std::vector<Edge<T>>>; #line 4 "graph/get_edges.hpp" template <class T> Edges<T> get_edges(Graph<T> &G) { int N = (int)G.size(), M = 0; for (int i = 0; i < N; i++) { for (auto &&e : G[i]) { M = std::max(M, e.id + 1); } } Edges<T> es(M); for (int i = N - 1; i >= 0; i--) { for (auto &&e : G[i]) { es[e.id] = e; } } return es; }