W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
Because of the latest mishaps of their agents, Central Intelligence Agency of Byteland resolved to improve their activity. So far the biggest trouble has been a preparation of safe meetings of agents. Your program has to help in solving this. For a given description of the net of roads in Byteland and the initial positions of two agents, it should answer if their safe meeting is possible.
To consider a meeting safe the agents must hold to the following precautions:
Write a program which:
In the first line of the standard input, there are two integers and separated by a single space, where , .
In the second line there are two integers and separated by a single space, , and , denoting respectively the starting positions of agents No 1 and No 2.
In the following lines there are pairs of natural numbers and separated by single spaces, and , denoting that there is a road from city to city .
There should be exactly one line in the standard input and it should contain:
For the input data:
6 7 1 5 1 2 4 5 2 3 3 4 4 1 5 4 5 6
the correct result is:
3
Task author: Tomasz Walen.