A certain bathroom has
Whenever someone enters the bathroom, they try to choose a stall that is as far from other people as possible. To avoid confusion, they follow deterministic rules: For each empty stall
When the last person chooses their stall
Input Specification
The first line of the input gives the number of test cases,
Output Specification
For each test case, output one line containing Case #x: y z
, where
Limits
Time limit: 60 seconds per test set.
Memory limit: 1GB.
Small Dataset 1
Small Dataset 2
Large Dataset
Sample Input
5
4 2
5 2
6 2
1000 1000
1000 1
Sample Output
Case #1: 1 0
Case #2: 1 0
Case #3: 1 1
Case #4: 0 0
Case #5: 500 499
In Sample Case #1, the first person occupies the leftmost of the middle two stalls, leaving the following configuration (O
stands for an occupied stall and .
for an empty one): O.O..O
. Then, the second and last person occupies the stall immediately to the right, leaving 1 empty stall on one side and none on the other.
In Sample Case #2, the first person occupies the middle stall, getting to O..O..O
. Then, the second and last person occupies the leftmost stall.
In Sample Case #3, the first person occupies the leftmost of the two middle stalls, leaving O..O...O
. The second person then occupies the middle of the three consecutive empty stalls.
In Sample Case #4, every stall is occupied at the end, no matter what the stall choices are.
In Sample Case #5, the first and only person chooses the leftmost middle stall.
Comments