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

34773번 - Expansion of the road network 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 2048 MB1000.000%

문제

Legend has it that, long ago, the Service of Braveway Connections (SBC) administered a network of bidirectional roads that connected various cities. At that time, the layout was extremely simple: between any two cities there was exactly one path.

With population growth and increased transportation of goods, the Institute of Connected and Planned Cities (ICPC) took control and decided to modernize the network. To avoid internal traffic in intermediate cities and speed up travel, new direct roads were built between certain pairs of cities. A new road was created between two cities $A$ and $B$ whenever, in the original layout, the path between them passed through exactly one intermediate city.

Today, we only have the current map of the network, and ICPC wants to find out whether it could indeed have arisen from this process.

Your task is to analyze the current map and determine whether the legend could be true. If possible, you should also reconstruct and print a possible original layout of the network.

입력

The first line contains two integers $N$ and $M$ (3ドル ≤ N ≤ 10^5,ドル 2ドル ≤ M ≤ 4 \times 10^5$), representing, respectively, the number of cities and the number of roads in the current map.

Each of the following $M$ lines contains two integers $u_i$ and $v_i$ (1ドル ≤ u_i , v_i ≤ N,ドル $u_i \ne v_i$), indicating that there is a bidirectional road between cities $u_i$ and $v_i$. In the current map, it is guaranteed that there is a path between any pair of cities and that there is at most one road between any pair of cities.

출력

If the current map could have arisen from the process described in the legend, the output should contain $N −1$ lines. Each line should contain two integers $a_i$ and $b_i$ (1ドル ≤ a_i , b_i ≤ N,ドル $a_i \ne b_i$), indicating that there was a direct road between cities $a_i$ and $b_i$ in the original layout.

Otherwise, the output should contain only one line with a single character “*” (asterisk).

If there is more than one possible original layout, print any of them.

제한

예제 입력 1

3 3
1 2
3 2
1 3

예제 출력 1

1 2
1 3

One possible original route is 1ドル − 2 − 3$. In this case, a single road was added by the process described in the legend, the road 1ドル − 3,ドル which passes through the intermediate city 2ドル$.

Other possible original routes are 1ドル − 3 − 2$ and 2ドル − 1 − 3$.

예제 입력 2

3 2
1 2
2 3

예제 출력 2

*

노트

출처

ICPC > Regionals > Latin America > Sub-Regional Brasil do ACM ICPC > Maratona SBC de Programação 2025 E번

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

출처

대학교 대회

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

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