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

31510번 - Eccentric Excursion 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 (추가 시간 없음) 2048 MB54161636.364%

문제

Eddy is planning a cross-country trip across $n$ different cities. There are $n-1$ roads connecting the cities. Each road connects two cities and is bidirectional. The roads are laid out such that it is possible to travel between any two cities using only roads.

Eddy wants to plan a trip so that he visits each city exactly once. He may start or end at any city. It might not be possible to visit each city exactly once using only roads. Luckily, Eddy can take a flight between any two cities that aren't directly connected by a road. Eddy would like to take exactly $k$ flights during his trip.

Help Eddy plan his trip.

입력

The first line contains two integers $n, k$ (0ドル \le k < n \le 500$) where $n$ is the number of cities Eddy is visiting and $k$ is the number of flights Eddy would like to take.

The next $n-1$ lines each contain two integers $a, b$ (1ドル \le a < b \le n$) indicating that there is a road between cities $a$ and $b$. It is guaranteed it is possible to travel from any city to any other city only using roads.

출력

Output $n$ integers that specify the sequence of cities that Eddy shall visit in order. The sequence must visit each city exactly once and use exactly $k$ flights. If there are multiple possible itineraries, output the lexicographically smallest sequence. If there is no possible itinerary, output $-1$.

제한

예제 입력 1

4 1
1 2
1 3
1 4

예제 출력 1

2 1 3 4

예제 입력 2

4 0
1 2
1 3
1 4

예제 출력 2

-1

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2023 ICPC Pacific Northwest Region > Division 1 E번

ICPC > Regionals > North America > Mid-Central Regional > 2023 Mid-Central USA Programming Contest F번

ICPC > Regionals > North America > South Central USA Regional > 2023 South Central USA Regional Contest > Division 1 E번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2023 Mid-Atlantic USA Regional Contest > Division 1 E번

ICPC > Regionals > North America > Southeast USA Regional > 2023 Southeast USA Regional Programming Contest > Division 1 E번

  • 문제를 만든 사람: Lewin Gan
(追記) (追記ここまで)

출처

대학교 대회

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

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