#C1894. Warehouse Level Closure Optimization
Warehouse Level Closure Optimization
Warehouse Level Closure Optimization
In a warehouse, there are n levels and m chutes connecting various levels. Due to new safety regulations, certain levels must be closed. The regulation requires closing a number of levels computed by the formula:
$$k = \min\left(n, \left\lfloor \frac{4n}{7} \right\rfloor\right) $$Your task is to decide which levels to close. For each test case, you are given n and m along with the chute connections (which do not affect the answer). You should output k (the number of levels to close) on one line, and on the next line, output any k distinct level indices from 1 to n (for example, the first k levels). If k is 0, output an empty line.
inputFormat
The first line of input contains an integer T representing the number of test cases.
For each test case:
- The first line contains two integers n and m, where n is the number of levels and m is the number of chutes.
- The next m lines each contain two integers u and v, representing a chute from level u to level v.
You can ignore the chute information for the purpose of calculating the answer.
outputFormat
For each test case, output two lines:
The first line contains the integer k (the number of levels to close).
The second line contains k space-separated integers representing the indices of levels to be closed. If k is 0, output an empty line.
4
4 6
1 2
1 3
2 3
2 4
3 4
3 4
5 5
1 2
2 3
3 4
4 5
1 3
1 0
6 8
1 2
2 3
3 4
4 5
5 6
1 3
2 4
3 5
2
1 2
2
1 2
0
3
1 2 3
</p>