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

33650번 - Triangle Trees 스페셜 저지다국어

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

문제

A triangle tree is an undirected graph in which every cycle contains exactly three edges. Recall that a cycle is a sequence of at least 3ドル$ distinct vertices $v_1,v_2,\dots ,v_k$ such that there is an edge between $v_i$ and $v_{i+1}$ for $i=1,\dots ,k-1$ and there is also an edge between $v_k$ and $v_1$.

A colouring of a graph is an assignment of colours to the vertices such that the two endpoints of each edge of the graph receive different colours. Given a triangle tree, your task is to find a colouring which uses the smallest possible number of colours.

Figure 1: Illustration of the second sample case. The number written just outside the vertex corresponds to the colour it receives corresponding to the output for that sample case.

입력

The first line of input contains two integers $N$ (1ドル≤N≤10^5$) and $M$ (0ドル≤M≤10^5$). The next $M$ lines each contain two integers $u$ and $v$ (1ドル≤u,v≤N$) indicating that the graph contains an edge between $u$ and $v$. It is guaranteed that $u \ne v,ドル all edges are unique, and that the graph is indeed a triangle tree.

출력

Output $N$ integers indicating the colours of vertices 1,2,ドル\dots ,N$ in order. If you used $k$ colours, the integers should be from the set $\{1,2,\dots ,k\}$. If there are multiple valid colourings, you may output any one of them. Recall the goal is to output such a colouring using the fewest colours possible, i.e. minimize $k$.

제한

예제 입력 1

3 3
1 2
2 3
3 1

예제 출력 1

2 3 1

예제 입력 2

7 8
1 2
1 7
2 7
3 4
3 7
4 7
5 7
6 7

예제 출력 2

3 2 3 2 2 2 1

예제 입력 3

5 4
1 2
1 3
2 4
2 5

예제 출력 3

1 2 2 1 1

힌트

출처

University > University of Alberta Programming Contest > UAPC 2024 > Division 1 J번

University > University of Alberta Programming Contest > UAPC 2024 > Division 2 J번

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

출처

대학교 대회

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

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