Sitting (Large)
Time limit5sMemory limit512 MB
Find the maximum number of players seatable in an R by C grid so no player has occupied seats on both sides horizontally or vertically.
- Level
Medium5 of 10
- Topics
- Greedy, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
The opening ceremony of a game world championship is about to start. The players sit in a grid of seats with rows and columns.
The competition is fierce, and a player dislikes having future opponents right next to them. A player feels crowded if another player sits in the seat directly to their left and another player sits in the seat directly to their right. A player also feels crowded if one player sits directly in front of them and another player sits directly behind them.
Find the largest number of players that can be seated so that no player feels crowded.
Input
The first line contains the number of test cases . test cases follow. Each test case is one line with two integers and : the number of rows and the number of columns of seats.
Output
For each test case, print one line in the form Case #x: y, where is the test case number starting from 1 and is the largest number of players that can be seated so that no player feels crowded.
Constraints
Note
With and , all four seats can be filled and no player feels crowded.
With and , a row cannot hold three players, because the middle one would feel crowded. Filling the first two columns seats four players, and nothing better exists.
With and , filling the first two rows and the last row is optimal and seats three players.