Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
File size: 3,174 Bytes
ab396f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Phineas is the proud owner of an enormous new fish tank! Looking at the fish
tank from the side, it can be represented as an infinite 2D plane. Phineas has
installed **N** vertical dividers into the tank, the _i_th of which is a line
segment connecting points (**Xi**, **Ai**) and (**Xi**, **Bi**). No two
dividers overlap at any point (including at their endpoints).

Unfortunately, Phineas's fish tank is lacking in fish, but he'll soon rectify
that! He's going to place one or more fish into the tank, with each one
initially occupying any point of his choice (each coordinate may be non-
integral and arbitrarily small or large). No fish's location may overlap with
any of the dividers (including their endpoints), but multiple fish may be
placed at the same coordinates.

After the fish have been placed, each one may swim left and right freely
(continuously decreasing or increasing its x-coordinate), as long as it never
touches a divider (including its endpoints). Fish do not block one another
from swimming, so multiple fish are able to occupy the same coordinates.
However, no fish is able to change its y-coordinate.

At any given moment, each fish feels that its personal space is violated if
any other fish is currently at the same x-coordinate as it (either at its
current y-coordinate, or arbitrarily far above or below it). As such, if two
fish ever occupy the same x-coordinate as one another, they both become
unhappy.

Phineas suspects that someone's planning on stealing one of his dividers soon
after he places fish into the tank!

And he wants to ensure that none of his fish have any chance of becoming
unhappy!

But he still wants to have as many fish as possible!

As such, he'd like to determine the maximum number of fish which he can place
into the tank such that, no matter which single one of the **N** dividers is
subsequently removed, and no matter how the fish then decide to swim around,
none of the fish can ever become unhappy.

### Input

Input begins with an integer **T**, the number of fish tanks. For each fish
tank, there is first a line containing the single integer **N**. Then, **N**
lines follow, the _i_th of which contains the 3 space-separated integers
**Xi**, **Ai**, and **Bi**.

### Output

For the _i_th fish tank, output a line containing "Case #_i_: " followed by
the maximum number of fish which Phineas can place into the tank with no risk
of unhappiness.

### Constraints

1 ≤ **T** ≤ 90  
1 ≤ **N** ≤ 500,000  
0 ≤ **Xi** ≤ 1,000,000,000  
0 ≤ **Ai** < **Bi** ≤ 1,000,000,000  

### Explanation of Sample

In the first case, Phineas could, for example, place a fish at coordinates (5,
5). If he placed another fish anywhere else in the tank (for example at
coordinates (-1, 2)), then if the single divider were removed, both fish would
be able to swim freely and might come to occupy the same x-coordinate as one
another.

In the second case, Phineas can place one fish at coordinates (-5, 5) and
another at coordinates (15, 5).

In the third case, no matter where Phineas might place two fish in the tank,
at least one choice of removed divider would result in them potentially
becoming unhappy.