#P6865. [RC-03] 染色

[RC-03] 染色

Background

Note: The input file is very large, so downloading may be slow (about 3 minutes). Please wait patiently.

This is an output-only problem. Please download the input data from here.

The answers you submit are best named in order as:

  • 01.out
  • 02.out
  • \dots
  • 18.out

Problem Description

Given an undirected graph, find a kk as small as possible such that the vertices can be divided into kk sets, and there is no edge between any two vertices in the same set.

Input Format

The first line contains three integers: n,m,k0n,m,k_0, meaning there are nn vertices and mm edges. As long as your kk satisfies kk0k\le k_0, you can get full score.

The next mm lines each contain two integers x,yx,y, describing an edge (x,y)(x,y). (1x,yn,xy)(1\le x,y\le n,x\ne y).

Output Format

Two lines. The first line contains an integer kk, your answer. (1kn)(1\le k\le n).

The second line contains nn integers. The ii-th integer indicates the set number aia_i that vertex ii is assigned to. (1aik)(1\le a_i\le k).

3 3 3
1 2
2 3
3 1
3
1 2 3

Hint

For each test point:

  • If your output is invalid, you will get 00 points.
  • If kk0k\le k_0, you will get full score.
  • Otherwise, you will get (suppose the full score of this test point is aa): a×k0k\lfloor a \times \dfrac{k_0}{k}\rfloor points.

There are 1818 test points in total. All test points satisfy 1n1051\le n\le 10^5, 1m5×1051\le m\le 5\times 10^5, and it is guaranteed that there exists a solution with kk0k\le k_0. The scores for each test point are as follows:

Test Point ID Score
141\sim 4 44
565\sim 6 55
7177\sim 17 66
1818 88

Translated by ChatGPT 5