Grafs (1) P56483


Statement
 

pdf   zip

html

Donat un graf dirigit amb n vèrtexs i m arcs, es vol saber si hi ha un camí dirigit entre dos vèrtexs.

Entrada

L’entrada comença amb n i m. Segueixen m parells u,v, amb uv, indicant un arc de u a v. Es té 0≤ u<n i 0≤ v<n i no hi ha arcs repetits. A continuació ve un parell x,y amb 0≤ x<n i 0≤ y <n.

Sortida

Escriviu “yes” o “no” depenent de si hi ha o no un camí de x a 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
    Catalan
    Other languages
    English
    Official solutions
    C++ Python Python
    User solutions
    C++ Python