QOJ.ac

QOJ

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

#3116. Ballot evaluation

Statistics

Before the 2009 elections at the European Parliament, Bill and Ted have asked their friends to make guesses about the outcome of the ballot. Now, the results have been published, so Bill and Ted want to check who was right. But checking the results of their many friends would take a very long time, and they need the evaluation to be done by a computer. Since they are not so good at programming, they ask you for help.

Input Specification

The data provided by Bill and Ted has the following format: The first line consists of the number $p$ of parties followed by the number $g$ of guesses (with $1 ≤ p ≤ 50$ and $1 ≤ g ≤ 10000$). Then follow $p$ lines, each line consisting of a unique party name of length $≤ 20$ (only containing letters a-z, A-Z and digits 0-9) and the achieved vote percentage of this party with one digit after the decimal point. After the parties follow $g$ lines, each consisting of a guess. A guess has the form $P_1 + P_2 + \cdots + P_k~ \mathbf{COMP}~ n$, where $P_1$ to $P_k$ are party names, $\mathbf{COMP}$ is one of the comparison operators <, >, <=, >= or = and $n$ is an integer between $0$ and $100$, inclusively. Each party name occurs at most once in each guess.

Output Specification

For each guess, sum up the vote percentages of the parties and compare them with the specified integer $n$. Then, print a line stating whether the guess was correct. See the sample output for details.

Sample Input

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

Sample Output

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

Notes

Be careful with the comparison of floating point values, because some values in the input (like 0.1) do not have an exact representation as a floating point number.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.