| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 54 | 21 | 15 | 31.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.
3 3 1 2 2 3 1 3
2 1 1
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 3 3 1 1
3 1 1 2
1 1 1