SP347 LAZYCOWS - Lazy Cows
Description
[English](/problems/LAZYCOWS/en/) [Vietnamese](/problems/LAZYCOWS/vn/)Farmer John regrets having applied high-grade fertilizer to his pastures since the grass now grows so quickly that his cows no longer need to move around when they graze. As a result, the cows have grown quite large and lazy... and winter is approaching.
Farmer John wants to build a set of barns to provide shelter for his immobile cows and believes that he needs to build his barns around the cows based on their current locations since they won't walk to a barn, no matter how close or comfortable.
The cows' grazing pasture is represented by a 2 x B (1
Input Format
The first line of the input contains integer t representing the number of test cases. Then t cases follow. Each case has the following form:
- Line 1: Three space-separated integers, N, K, and B.
- Lines 2..N+1: Two space-separated integers in the range (1,1) to (2,B) giving the coordinates of the cell containing each cow. No cell contains more than one cow.
Output Format
For each test case, output the minimum area required by the K barns in order to cover all of the cows.
Explanation/Hint
Input details: As pictured above.
Output details: As discussed above.