Brownie Points II
Time limit1sMemory limit128 MB
Given points in the plane, Stan picks a vertical line and Ollie a horizontal line through it; find Stan's guaranteed score and the distinct best Ollie scores.
- Level
Hard8 of 10
- Topics
- Sorting, Prefix sum, Greedy, Implementation
- Solved
- No attempts yet
Problem
Stan and Ollie play the game of Odd Brownie Points. Several brownie points lie in the plane at integer coordinates.
Stan moves first and draws a vertical line. This line must pass through at least one brownie point (that is, its -coordinate must equal the -coordinate of some point, and it may pass through several points that share that -coordinate at once). Ollie then draws a horizontal line, which must pass through one of the brownie points that already lie on Stan's vertical line.
The two lines split the plane into four quadrants. The quadrant containing points with arbitrarily large positive coordinates is the top-right quadrant. A brownie point lying exactly on either line is crossed and counts for no one.
- Stan scores one point for every uncrossed brownie point in the top-right or bottom-left quadrant.
- Ollie scores one point for every uncrossed brownie point in the top-left or bottom-right quadrant.
Each player tries to maximize his own score. Moving first, Stan anticipates Ollie's reply and chooses the vertical line that maximizes the smallest score he can be sure of.
Input
The input consists of several test cases. The first line of each test case contains an odd integer with , the number of brownie points. Each of the next lines contains two integers and with , the coordinates of one brownie point. No two points share the same location. The input ends with a line containing a single .
Output
For each test case, print one line. First print the largest score Stan can guarantee for himself. Then, over all vertical lines that achieve this guaranteed score, print each distinct score Ollie can obtain with his best reply, in increasing order. The output format is exactly:
Stan: S; Ollie: o1 o2 ... ok;