QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 128 MB 満点: 100

#3116. 选票评估

統計

在 2009 年欧洲议会选举之前,Bill 和 Ted 请他们的朋友对投票结果进行预测。现在,选举结果已经公布,Bill 和 Ted 想检查谁的预测是正确的。但是,检查他们众多朋友的预测结果会花费很长时间,他们需要计算机来完成这项评估。由于他们不太擅长编程,他们请求你的帮助。

输入格式

Bill 和 Ted 提供的数据格式如下:第一行包含政党数量 $p$ 和预测数量 $g$(其中 $1 \le p \le 50$ 且 $1 \le g \le 10000$)。接下来是 $p$ 行,每行包含一个长度不超过 $20$ 的唯一政党名称(仅包含字母 a-zA-Z 和数字 0-9)以及该政党获得的得票百分比(保留一位小数)。政党信息之后是 $g$ 行,每行包含一个预测。预测的形式为 $P_1 + P_2 + \cdots + P_k~ \mathbf{COMP}~ n$,其中 $P_1$ 到 $P_k$ 是政党名称,$\mathbf{COMP}$ 是比较运算符 <, >, <=, >== 之一,$n$ 是一个 $0$ 到 $100$ 之间的整数。每个政党名称在每个预测中最多出现一次。

输出格式

对于每个预测,将所涉及政党的得票百分比相加,并与指定的整数 $n$ 进行比较。然后,打印一行说明该预测是否正确。详情请参阅样例输出。

样例

样例输入 1

6 5
CDU 30.7
SPD 20.8
Gruene 12.1
FDP 11.0
DIELINKE 7.5
CSU 7.2
FDP > 11
CDU + SPD < 50
SPD + CSU >= 28
FDP + SPD + CDU <= 42
CDU + FDP + SPD + DIELINKE = 70

样例输出 1

Guess #1 was incorrect.
Guess #2 was incorrect.
Guess #3 was correct.
Guess #4 was incorrect.
Guess #5 was correct.

说明

在比较浮点数值时要小心,因为输入中的某些值(如 0.1)在浮点数表示中无法精确存储。

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.