HATEAM - E - Football Team
A football team will be standing in rows to have a photograph taken. The location of each player will be given by two integers x and y, where y gives the number of the row, and x gives the distance of the player from the left edge of the row. The x values will be all different.
In order to make the photo more interesting, you're going to make sure players who are near each other have shirts of different colors. To do this, you set the following rule:
For each player P:
- The closest player to the right of P in the same row, if there is such a player, must have a different shirt color.
- The closest player to the right of P in the previous row, if there is such a player, must have a different shirt color.
- The closest player to the right of P in the next row, if there is such a player, must have a different shirt color.
More formally, if there is a player at (x1,y1) and (x2,y2), where x1 Find the minimum number of distinct shirt colors required so that this is possible. The first line of input contains a single integer T, the number of test cases. Each test case starts with a line that contains an integer N, the number of players, followed by N lines of the form each specifying the position of one player. For each test case, output where X is the test case number, starting from 1, and c is the minimum number of colors required. 1 ≤ T ≤ 100 Small dataset 1 ≤ y ≤ 15 Large dataset 1 ≤ y ≤ 30
Input
x y
Output
Case #X: c
Limits
1 ≤ x ≤ 1000
The values of x will all be different.
1 ≤ N ≤ 100
1 ≤ N ≤ 1000Sample
Input
3
3
10 10
8 15
12 7
5
1 1
2 1
3 1
4 1
5 1
3
1 1
2 2
3 1
Output
Case #1: 1
Case #2: 2
Case #3: 3
Added by: | Alvaro Javier Medina Balboa |
Date: | 2010-10-15 |
Time limit: | 5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 NODEJS OBJC VB.NET |