Created
May 10, 2018 18:17
-
-
Save jordi-petit/158007530284c298a568de9a74e716cf to your computer and use it in GitHub Desktop.
AP2 2018-05-10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jutge import read | |
def dfs(G, u, y, vis): | |
if not vis[u]: | |
vis[u] = True | |
for v in G[u]: | |
if vis[y]: | |
return | |
dfs(G, v, y, vis) | |
def main(): | |
n, m = read(int, int) | |
G = [[] for i in range(n)] | |
for i in range(m): | |
u, v = read(int, int) | |
G[u].append(v) | |
x, y = read(int, int) | |
vis = [False for i in range(n)] | |
dfs(G, x, y, vis) | |
print("yes" if vis[y] else "no") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment