#P10094. [ROIR 2023] 矩形分割 (Day 1)
[ROIR 2023] 矩形分割 (Day 1)
Background
Translated from ROIR 2023 D1T1。
Problem Description
There is a rectangle of size made of unit grid cells. You need to split it into smaller rectangles using vertical or horizontal cuts. The smaller rectangles do not need to have the same size.
Each cut is not allowed to stop halfway: it must go from one side of the current rectangle to the opposite side. Cuts are only allowed along grid lines.
Input Format
The first line contains an integer , the number of test cases.
The next lines each contain one test case. Each test case has four integers , representing the rectangle size (length and width), the required number of cuts, and the required number of resulting smaller rectangles.
Output Format
For each test case, output in one line the number of horizontal cuts () and the number of vertical cuts () that can split the rectangle into smaller rectangles. If there are multiple ways, output the one with fewer horizontal cuts. If it is impossible to cut as required, output -1.
3
2 2 1 2
1 2 2 3
3 5 5 12
0 1
-1
2 3
Hint
This problem uses bundled testdata.
| Subtask ID | Score | Special Property |
|---|---|---|
| None |
All testdata satisfy , , , , and .
Translated by ChatGPT 5