Graphs (1) P56483


Statement
 

pdf   zip

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

Input

Input starts with nn i mm. Then follow mm pairs u,vu,v, with uvu \ne v, indicating an arc from uu to vv. We have that 0u<n0\le u<n and 0v<n0\le v<n and there are no repeated arcs. Then follows, a pair x,yx,y with 0x<n0\le x<n and 0y<n0\le y <n.

Output

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

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