Graphs (1) P56483


Statement
 

pdf   zip

thehtml

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 uv, 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.

Public test cases
  • Input

    8 10
    1 4  4 6  7 2  7 5  0 3  2 5  5 2  6 3  1 0  0 1
    1 3
    

    Output

    yes
    
  • Input

    8 10
    1 4  4 6  7 2  7 5  0 3  2 5  5 2  6 3  1 0  0 1
    7 6
    

    Output

    no
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Jordi Petit
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python Python
    User solutions
    C++ Python