Advertisement
Guest User

Untitled

a guest
May 28th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. 11629 Ballot evaluation
  2. Before the 2009 elections at the European Parliament, Bill and Ted have asked their friends to make
  3. guesses about the outcome of the ballot. Now, the results have been published, so Bill and Ted want
  4. to check who was right. But checking the results of their many friends would take a very long time,
  5. and they need the evaluation to be done by a computer. Since they are not so good at programming,
  6. they ask you for help.
  7. Input
  8. The data provided by Bill and Ted has the following format: The first line consists of the number p of
  9. parties followed by the number g of guesses (with 1 <= p <= 50 and 1 <= g <= 10000). Then follow p lines,
  10. each line consisting of a unique party name of length  20 (only containing letters ‘a’-‘z’, ‘A’-‘Z’ and
  11. digits ‘0’-‘9’) and the achieved vote percentage of this party with one digit after the decimal point. After
  12. the parties follow g lines, each consisting of a guess. A guess has the form P1+P2+: : :+Pk COMP n,
  13. where P1 to Pk are party names, COMP is one of the comparison operators ‘<’, ‘>’, ‘<=’, ‘>=’ or ‘=’
  14. and n is an integer between 0 and 100, inclusively. Each party name occurs at most once in each guess.
  15. Output
  16. For each guess, sum up the vote percentages of the parties and compare them with the specified integer
  17. n. Then, print a line stating whether the guess was correct. See the sample output for details.
  18. Note: Be careful with the comparison of floating point values, because some values in the input (like
  19. 0.1) do not have an exact representation as a floating point number.
  20. Sample Input
  21. 6 5
  22. CDU 30.7
  23. SPD 20.8
  24. Gruene 12.1
  25. FDP 11.0
  26. DIELINKE 7.5
  27. CSU 7.2
  28. FDP > 11
  29. CDU + SPD < 50
  30. SPD + CSU >= 28
  31. FDP + SPD + CDU <= 42
  32. CDU + FDP + SPD + DIELINKE = 70
  33. Sample Output
  34. Guess #1 was incorrect.
  35. Guess #2 was incorrect.
  36. Guess #3 was correct.
  37. Guess #4 was incorrect.
  38. Guess #5 was correct.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement