(Smurf)Land protection
시간 제한5초메모리 제한512 MB
각 정점을 지웠을 때 방향 그래프의 강한 연결 성분 수가 그대로인지 판정한다.
문제
In SmurfLand there are Smurf villages and roads connecting them. Each road can be used to transport goods only in one direction. Some roads may lead from some village to itself and there might be more than one road connecting a pair of villages. The Smurfs have developed trade unions. Each trade union is a maximal subset of villages with the property that it is possible to transport goods from any village to any other village inside that trade union. Gargamel is planning to destroy one of the villages. It would be a disaster if after the village is destroyed the number of trade unions would have to increase. Help Smurfs decide which villages will need to be protected to ensure that the disaster doesn't happen.
입력
The first line of input contains two integers and (, ) -- the number of villages and roads. The next lines describe the roads: each line contains two integers () specifying that there is a road directly connecting villages with numbers and .
출력
Ouput lines: th line should contain the word "YES" (without quotes) if Smurfs must protect th village or the word "NO" otherwise.