Grafs (2)

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

Input

Input starts with the value of n and the n names of the vertices. Then
comes the value of m and follow the m arcs, made up by the name of two
vertices, without repetitions nor autoloops. Then follows a pair of
vertices x, y. You can assume that x and y belong to the graph.

Output

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

Problem information

Author: Jordi Petit

Generation: 2026-01-25T10:31:41.683Z

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