Logo
(追記) (追記ここまで)

11745번 - King’s Inspection 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 512 MB293372813.397%

문제

King Karl is a responsible and diligent ruler. Each year he travels across his country to make certain that all cities are doing well.

There are n cities in his country and m roads. In order to control the travelers, each road is unidirectional, that is a road from city a to city b can not be passed from b to a.

Karl wants to travel along the roads in such a way that he starts in the capital, visits every non-capital city exactly once, and finishes in the capital again.

As a transport minister, you are obliged to find such a route, or to determine that such a route doesn’t exist.

입력

The first line contains two integers n and m (2 ≤ n ≤ 100 000, 0 ≤ m ≤ n + 20) — the number of cities and the number of roads in the country.

Each of the next m lines contains two integers ai and bi (1 ≤ ai, bi ≤ n), meaning that there is a one-way road from city ai to city bi. Cities are numbered from 1 to n. The capital is numbered as 1.

출력

If there is a route that passes through each non-capital city exactly once, starting and finishing in the capital, then output n + 1 space-separated integers — a list of cities along the route. Do output the capital city both in the beginning and in the end of the route.

If there is no desired route, output “There is no route, Karl!” (without quotation marks).

제한

예제 입력 1

4 6
1 4
4 1
4 2
2 1
3 4
1 3

예제 출력 1

1 3 4 2 1

예제 입력 2

4 3
1 4
1 4
2 2

예제 출력 2

There is no route, Karl!

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > NEERC 2015 K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /