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

31293번 - Graph Coloring 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB54211531.915%

문제

You are given a bidirectional graph where the degree of each vertex is at most 5. Paint its vertices in 3 colors in such a way that each vertex $v$ has no more than one neighbor of the same color as $v$.

입력

On the first line, there are two integers $n$ and $m$: the number of vertices and the number of edges (1ドル \le n \le 100,000円$).

Each of next $m$ lines contains two integers $a$ and $b$: the numbers of vertices connected by an edge (1ドル \le a, b \le n$).

It is guaranteed that there are no loops or multiple edges in the graph, and the degree of each vertex is at most 5.

출력

It there is no valid coloring, print one number "-1" (without quotes). Otherwise, print $n$ integers $c_1,ドル $c_2,ドル $\ldots,ドル $c_n$: the colors of all vertices (1ドル \le c_i \le 3$). If there is more than one solution, print any one of them.

제한

예제 입력 1

3 3
1 2
2 3
1 3

예제 출력 1

2 1 1

예제 입력 2

6 15
1 2
1 3
1 4
1 5
1 6
2 3
2 4
2 5
2 6
3 4
3 5
3 6
4 5
4 6
5 6

예제 출력 2

2 2 3 3 1 1

예제 입력 3

3 1
1 2

예제 출력 3

1 1 1

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 1: Grand Prix of SPb C번

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

출처

대학교 대회

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

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