From 156fe8e912c67d69688c8505dc65b6470dfc0d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=83=D0=B7=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=9F=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=BE?= <124675990+CrazyDuck192@users.noreply.github.com> Date: Wed, 29 Mar 2023 21:56:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D1=87=D0=B0=20=D0=B7?= =?UTF-8?q?=20Eolymp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ways.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ways.py diff --git a/ways.py b/ways.py new file mode 100644 index 0000000..4d29f0c --- /dev/null +++ b/ways.py @@ -0,0 +1,36 @@ +def dfs(start, depth): + global res + if depth > d: + return + if start == b: + res += 1 + return + used[start-1] = 1 + for i in range(n): + if g[start-1][i] == 1 and used[i] == 0: + dfs(i+1, depth+1) + used[start-1] = 0 + +n, k, a, b, d = map(int, input().split()) + +g = [[0]*n for i in range(n)] +used = [0]*n + +for i in range(k): + a1, a2 = map(int, input().split()) + g[a1-1][a2-1] = 1 + +res = 0 +def realization(): + global res + dfs(a, 0) + return res + +print(realization()) + + + + + + +