QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#12609. 鱼

Statistics

JOI 君突然想养鱼。

JOI 君去了家附近的宠物店,店里有 $N$ 条鱼在售。第 $i$ 条鱼的体长为 $L_i$ cm,颜色为红、绿、蓝中的一种。JOI 君决定从这 $N$ 条鱼中挑选至少 1 条带回家养。

养鱼时需要注意一件事:如果同时饲养大鱼和小鱼,大鱼会吃掉小鱼。具体来说,当鱼 X 的体长是鱼 Y 体长的 2 倍以上时,如果同时饲养 X 和 Y,X 就会吃掉 Y。因此,不能同时饲养这样的两条鱼。

JOI 君想知道,他所饲养的鱼的颜色组合有多少种可能。所谓两种颜色组合不同,是指红、绿、蓝三种颜色的鱼的数量中,至少有一种颜色的数量不同。已知宠物店里售卖的鱼的体长和颜色,请计算 JOI 君饲养的鱼的颜色组合可能有多少种。

题目描述

给定宠物店里售卖的鱼的体长和颜色,编写一个程序,输出 JOI 君饲养的鱼的颜色组合可能有多少种。

数据范围

$1 \le N \le 500\,000$ 鱼的数量 $1 \le L_i \le 1\,000\,000\,000$ 第 $i$ 条鱼的体长

输入格式

从标准输入读取以下内容:

  • 第 1 行包含一个整数 $N$。$N$ 表示宠物店里售卖的鱼的数量。
  • 第 $1+i$ 行 ($1 \le i \le N$) 包含一个整数 $L_i$ 和一个字符 $C_i$,中间用空格分隔。字符 $C_i$ 为 R、G、B 中的任意一个。这表示第 $i$ 条鱼的体长为 $L_i$ cm,若 $C_i$ 为 R,则第 $i$ 条鱼的颜色为红色;若 $C_i$ 为 G,则第 $i$ 条鱼的颜色为绿色;若 $C_i$ 为 B,则第 $i$ 条鱼的颜色为蓝色。

输出格式

将 JOI 君饲养的鱼的颜色组合可能有多少种的结果输出到标准输出,占 1 行。

子任务

  • 测试数据中,10% 的分数满足 $N \le 100$。
  • 测试数据中,30% 的分数满足 $N \le 2000$。

样例

样例输入 1

4
10 R
4 G
8 B
5 B

样例输出 1

6

说明 1

第 1 条鱼会吃掉第 2 条鱼,因此不能同时饲养它们。第 1 条和第 4 条、第 2 条和第 3 条的情况也一样。因此,可能的颜色组合有:“红 1 条”、“绿 1 条”、“蓝 1 条”、“红 1 条和蓝 1 条”、“绿 1 条和蓝 1 条”、“蓝 2 条”,共 6 种。

样例输入 2

10
26 B
10 B
16 G
20 R
6 R
5 G
13 G
40 R
8 R
33 R

样例输出 2

13

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.