#K51722. Minimum Buckets Problem
Minimum Buckets Problem
Minimum Buckets Problem
You are given a warehouse represented as a grid with dimensions \( L \) (the number of rows) and \( W \) (the number of columns). Some cells in the grid have leaks. The leaks are specified as integer positions in row-major order, i.e. the cell at row \( r \) and column \( c \) has an index \( r \times W + c \). A single bucket can cover leaks in one cell and also cover its immediate right adjacent cell if they are on the same row. Your task is to determine the minimum number of buckets required to cover all the leaks in the warehouse.
Note: Two leaks are considered to be covered by the same bucket if they appear on the same row and either in the same column or in two consecutive columns.
inputFormat
The first line contains an integer ( T ) representing the number of test cases. For each test case, the first line contains three space-separated integers ( L ), ( W ), and ( n ), where ( n ) is the number of leaks. If ( n > 0 ), the second line contains ( n ) space-separated integers indicating the positions of the leaks. If ( n = 0 ), the second line is omitted.
outputFormat
For each test case, output a single line containing the minimum number of buckets required.## sample
1
3 3 4
0 1 4 8
3
</p>