#P15660. [ICPC 2025 Jakarta R] Two Sets

[ICPC 2025 Jakarta R] Two Sets

题目描述

You are given an undirected graph with NN vertices and MM edges, with vertices numbered from 11 to NN.

You have to select two integers pp and qq such that:

  • N<(p+1)(q+1)N < (p + 1)(q + 1)
  • There exists a non-empty set of vertices S1S_1 such that for every vertex uS1u \in S_1, there are at least\textbf{at least} pp other vertices in S1S_1 that share an edge with uu.
  • There exists a set of vertices S2S_2 of size at least\textbf{at least} qq such that for every vertex uS2u \in S_2, there are no vertices in S2S_2 that share an edge with uu.

You have to find pp, qq, along with any S1S_1 and S2S_2 that satisfy the requirements above. It can be proven that such pp and qq always exist.

输入格式

The first line contains two integers NN and MM (1N20001 \leq N \leq 2000; 0Mmin(N(N1)2,200  0000 \leq M \leq \min(\frac{N(N-1)}{2}, 200\;000)).

Each of the next MM lines contains two integers uu and vv (1u<vN1 \leq u < v \leq N) representing the two vertex numbers that are connected by an edge.

All the given edges are different.

输出格式

The first line contains two integers pp and qq.

The second line contains an integer S1|S_1| followed by S1|S_1| integers representing the vertex numbers in S1S_1.

The third line contains an integer S2|S_2| followed by S2|S_2| integers representing the vertex numbers in S2S_2.

4 2
1 2
3 4
1 2
2 1 2
2 3 1

提示

Explanation of Sample 1:\textit{Explanation of Sample 1:} You selected p=1p = 1, q=2q = 2, S1={1,2}S_1 = \{1, 2\}, and S2={1,3}S_2 = \{1, 3\}.