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

24707번 - Soccer Match 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB84450.000%

문제

As a big sports fan, you, the primary leader of the Pigeon Kingdom, are organizing a soccer match! A total of $N$ players signed up for the match, and you plan to divide them into three groups: Red team, Blue team, and spectators. The number of players in the Red team and the Blue team can be different.

There are $M$ pairs of friends among the $N$ participants, where $M \ge 2KN$ for some given constant $K \ge 1$. The friendship is mutual, which means that if $a$ is a friend of $b,ドル then $b$ is a friend of $a,ドル and vice versa. To make the match more exciting, you want to make sure that each player in the Red team has at least $K + 1$ friends in the Blue team, and each player in the Blue team has at least $K + 1$ friends in the Red team. Can you find an arrangement satisfying such constraints?

입력

The first line contains one integer $T$ (1ドル\le T\le50,000円$), denoting the number of test cases. For each test case:

The first line contains three integers, $N,ドル $M,ドル and $K$ (1ドル \le N, M, K \le 50,000円$ and $M \ge 2KN$), denoting the number of players, the number of pairs of friends, and the given constant, respectively.

Then $M$ lines follow, each containing two integers $u$ and $v$ (1ドル \le u < v \le N$), denoting that $u$ and $v$ are friends.

It is guaranteed that, in each test case, each pair of $(u, v)$ appears at most once, and the sum of $M$ over all test cases does not exceed 50ドル,000円$.

출력

For each test case, output two lines:

The first line begins with one integer $R(R > 0),ドル denoting the number of players in the Red team. Then $R$ space-separated integers follow, each denoting the index of a player in the Red team.

The second line follows the same format. It begins with an integer $B(B > 0),ドル denoting the number of players in the Blue team. Then $B$ space-separated integers follow, each denoting the index of a player in the Blue team.

If there are multiple solutions, you can output any one of them. It can be shown that, under such constraints, a solution always exists.

제한

예제 입력 1

2
5 10 1
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
10 20 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
1 10
1 4
4 7
7 10
3 10
3 6
6 9
2 9
2 5
5 8
1 8

예제 출력 1

3 2 3 4
2 1 5
3 2 8 10
2 1 9

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2022 > Day 6: ICPC Camp Day 1: PKU Contest A번

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

출처

대학교 대회

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

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