#P17768. 「LDOI R2」卡牌 / Cards
「LDOI R2」卡牌 / Cards
Problem Description
There are players participating in a card game.
Each player holds one card for each number from to (). In each round of the game, every player plays one card, with the requirement that the sum of all played card numbers in that round must equal . Each card can be used by a player only once. The game ends when no valid card combination can satisfy the round's sum requirement.
Determine the maximum number of rounds they can play and provide a feasible playing strategy.
Input Format
There are multiple test cases for this problem.
The first line contains a positive integer , representing the number of test cases.
The next lines each contain two positive integers and .
Output Format
For each test case:
- The first line contains a positive integer , representing the maximum number of rounds.
- The following lines each contain numbers, representing the cards played by each player in that round. Any valid solution is acceptable.
3
2 2
10 3
8 5
3
0 2
2 0
1 1
7
0 3 7
8 2 0
1 8 1
5 1 4
3 4 3
4 0 6
2 6 2
4
0 3 4 0 1
4 1 2 1 0
1 2 1 2 2
2 0 0 3 3
Hint
Explanation
In the first test case, the output's second through fourth lines show the cards played by the two players across rounds, where each round's card numbers sum to . It can be proven that the maximum number of possible rounds is indeed .
Constraints
This problem uses subtask scoring.
The output may be large, please use fast output methods.
| Subtask | Conditions | Score |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | is even | |
| 4 | ||
| 5 | None |
For all test cases, , , , .