Graphs (1)

Given a directed graph with m vertices and m arcs, we wish to know if
there is a directed path between two given vertices.

Input

Input starts with n i m. Then follow m pairs u, v, with u ≠ v,
indicating an arc from u to v. We have that 0 ≤ u < n and 0 ≤ v < n and
there are no repeated arcs. Then follows, a pair x, y with 0 ≤ x < n and
0 ≤ y < n.

Output

Write “yes” o “no” according to whether there is or not a path from x to
y.

Problem information

Author: Jordi Petit
Translator: Jordi Petit

Generation: 2026-01-25T11:22:50.547Z

© Jutge.org, 2006–2026.
https://jutge.org
