#P1692. 部落卫队

部落卫队

Description

In the primitive Byteland tribe, residents often clash over limited resources. Almost every resident has enemies. To organize a force to defend the tribe, the chief wants to select as many residents as possible so that no two selected people are enemies.

Given the enmity relations among residents of the Byteland tribe, compute the optimal composition of the tribal guard. If multiple solutions are feasible, output the lexicographically largest one.

Input Format

The first line contains two positive integers nn and mm, indicating that there are nn residents in the Byteland tribe and mm enmity relations. Residents are numbered 1,2,,n1,2,\cdots,n. Each of the next mm lines contains two positive integers uu and vv, indicating that residents uu and vv are enemies.

Output Format

The first line is the number of people in the tribal guard. The second line contains the composition xix_i, 1in1 \le i \le n, where xi=0x_i = 0 means resident ii is not in the guard, and xi=1x_i = 1 means resident ii is in the guard.

7  10
1  2
1  4
2  4
2  3
2  5
2  6
3  5
3  6
4  5
5  6
3
1 0 1 0 0 0 1

Hint

For 60%60\% of the testdata: n20n \le 20, m100m \le 100.

For all testdata: n100n \le 100, m3000m \le 3000. The testdata are uniformly sampled at random from all valid instances.

Translated by ChatGPT 5