This documentation is automatically generated by online-judge-tools/verification-helper
#include "src/graph/Read-Graph.hpp"
std::vector<std::vector<int>> read_graph(int n, int m, bool undirect = true, bool minus = true)
グラフを隣接リスト表現で受け取ります
n
: 頂点数m
: 辺数undirect
: 無向グラフか否か(デフォルトでtrue)minus
: 1-indexedか否か(デフォルトでtrue)返り値
: std::vector<std::vector<int>>
read_tree
: $m = n - 1$ のread_graph
を呼び出します。(つまり木)#pragma once
#include <vector>
#include <iostream>
namespace zawa {
std::vector<std::vector<int>> read_graph(int n, int m, bool undirect = true, bool minus = true) {
std::vector<std::vector<int>> res(n, std::vector(0, 0));
for (int _ = 0 ; _ < m ; _++) {
int u, v;
std::cin >> u >> v;
res[u - minus].emplace_back(v - minus);
if (undirect) {
res[v - minus].emplace_back(u - minus);
}
}
return res;
}
std::vector<std::vector<int>> read_tree(int n, bool undirect = true, bool minus = true) {
return read_graph(n, n - 1, undirect, minus);
}
}
#line 2 "src/graph/Read-Graph.hpp"
#include <vector>
#include <iostream>
namespace zawa {
std::vector<std::vector<int>> read_graph(int n, int m, bool undirect = true, bool minus = true) {
std::vector<std::vector<int>> res(n, std::vector(0, 0));
for (int _ = 0 ; _ < m ; _++) {
int u, v;
std::cin >> u >> v;
res[u - minus].emplace_back(v - minus);
if (undirect) {
res[v - minus].emplace_back(u - minus);
}
}
return res;
}
std::vector<std::vector<int>> read_tree(int n, bool undirect = true, bool minus = true) {
return read_graph(n, n - 1, undirect, minus);
}
}