QOJ.ac

QOJ

时间限制: 2 s 内存限制: 256 MB 总分: 100

#21116. 乳牛矩形

统计

Farmer John 的 $N$ 頭牛位於二維平面上互不相同的點,$1 \leq N \leq 500$。牛有 Holsteins 和 Guernseys 兩個品種。他想建邊平行座標軸的矩形圍欄,只圍住 Holsteins,不含 Guernseys(圍欄邊界上的牛也算被圍住)。首先要圍住盡可能多的 Holsteins,再在這樣的圍欄中選面積最小的。請求出此面積。寬或高為零的圍欄也允許。

輸入格式

第一行包含 $N$。接下來 $N$ 行每行以兩個整數和一個字元描述一頭牛。整數給出位置 $(x,y)$($0 \leq x, y \leq 1000$),字元 $H$ 或 $G$ 表示品種。任意兩頭牛位置不同,保證至少一頭 Holstein。

輸出格式

輸出兩個整數。第一行是不含 Guernseys 的圍欄最多能圍住的 Holsteins 數,第二行是這種圍欄的最小面積。

範例

輸入格式 1

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

輸出格式 1

2
1

題目作者:Nick Wu,2015

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.