#3885. [Usaco2015 Jan]Cow Rectangles

[Usaco2015 Jan]Cow Rectangles

题目描述

The locations of Farmer John's nn cows are described by distinct points in the 2D plane. The cows belong to two different breeds: Holsteins and Guernseys. Farmer John wants to build a rectangular fence with sides parallel to the coordinate axes enclosing only Holsteins, with no Guernseys (a cow counts as enclosed even if it is on the boundary of the fence). Among all such fences, Farmer John wants to build a fence enclosing the maximum number of Holsteins. And among all these fences, Farmer John wants to build a fence of minimum possible area. Please determine this area. A fence of zero width or height is allowable.

翻译:

坐标系上给出 nn 个点,分 HHGG,一个整点坐标上至多一个点。 现在求一个不包含 GG 的且包含尽量多 HH 的子矩形,然后在保证 HH 最多的情况下问子矩形的最小面积。 输出 HH 的最大数量,和保证 HH 最多时的最小矩形面积。

输入格式

The first line of input contains nn.

Each of the next nn lines describes a cow, and contains two integers and a character. The integers indicate a point (x,y)(x,y) at which the cow is located. The character is HH or GG,indicating the cow's breed. No two cows are located at the same point, and there is always at least one Holstein.

输出格式

Print two integers. The first line should contain the maximum number of Holsteins that can be enclosed by a fence containing no Guernseys,and second line should contain the minimum area enclosed by such a fence.

5
1 1 H
2 2 H
3 3 G
4 4 H
6 6 H
2
1

数据规模与约定

对于 100%100\% 的数据,1n5001\le n\le 5000x,y1030\le x,y\le10^3

题目来源

Gold & 鸣谢18357