From 8072707be54edbbf6add3f53e682199679c33398 Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Sun, 13 Nov 2016 22:42:01 +0100 Subject: Algorithms : add 03-algorithms_on_graphs 01-decomposition --- .../01-reachability/reachability.cpp | 26 ++++++++++++++++++++++ .../01-decomposition/01-reachability/tests/01 | 6 +++++ .../01-decomposition/01-reachability/tests/01.a | 1 + .../01-decomposition/01-reachability/tests/02 | 4 ++++ .../01-decomposition/01-reachability/tests/02.a | 1 + 5 files changed, 38 insertions(+) create mode 100644 03-algorithms_on_graphs/01-decomposition/01-reachability/reachability.cpp create mode 100644 03-algorithms_on_graphs/01-decomposition/01-reachability/tests/01 create mode 100644 03-algorithms_on_graphs/01-decomposition/01-reachability/tests/01.a create mode 100644 03-algorithms_on_graphs/01-decomposition/01-reachability/tests/02 create mode 100644 03-algorithms_on_graphs/01-decomposition/01-reachability/tests/02.a (limited to '03-algorithms_on_graphs/01-decomposition/01-reachability') diff --git a/03-algorithms_on_graphs/01-decomposition/01-reachability/reachability.cpp b/03-algorithms_on_graphs/01-decomposition/01-reachability/reachability.cpp new file mode 100644 index 0000000..cb2e76f --- /dev/null +++ b/03-algorithms_on_graphs/01-decomposition/01-reachability/reachability.cpp @@ -0,0 +1,26 @@ +#include +#include + +using std::vector; +using std::pair; + + +int reach(vector > &adj, int x, int y) { + //write your code here + return 0; +} + +int main() { + size_t n, m; + std::cin >> n >> m; + vector > adj(n, vector()); + for (size_t i = 0; i < m; i++) { + int x, y; + std::cin >> x >> y; + adj[x - 1].push_back(y - 1); + adj[y - 1].push_back(x - 1); + } + int x, y; + std::cin >> x >> y; + std::cout << reach(adj, x - 1, y - 1); +} diff --git a/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/01 b/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/01 new file mode 100644 index 0000000..d7bb894 --- /dev/null +++ b/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/01 @@ -0,0 +1,6 @@ +4 4 +1 2 +3 2 +4 3 +1 4 +1 4 diff --git a/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/01.a b/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/01.a new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/01.a @@ -0,0 +1 @@ +1 diff --git a/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/02 b/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/02 new file mode 100644 index 0000000..e27d40b --- /dev/null +++ b/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/02 @@ -0,0 +1,4 @@ +4 2 +1 2 +3 2 +1 4 diff --git a/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/02.a b/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/02.a new file mode 100644 index 0000000..573541a --- /dev/null +++ b/03-algorithms_on_graphs/01-decomposition/01-reachability/tests/02.a @@ -0,0 +1 @@ +0 -- cgit v1.2.3