A gaming tournament keeps a scoreboard listing each registered player's point total. Players love trash-talking each other with "rivalry claims" -- each claim names two players and a comparison symbol, asserting how their scores relate. Given the scoreboard and a list of claims, determine whether each claim is actually true according to the recorded scores.
The first line contains a single integer n, the number of players.
Each of the next n lines contains a player's name and their integer score, separated by a space: name value. Names are distinct, non-empty strings of lowercase English letters and digits, at most 20 characters long.
The next line contains a single integer q, the number of claims.
Each of the next q lines contains a claim in the form leftName op rightName, where op is one of >, <, or =. Both leftName and rightName are guaranteed to be names that appear on the scoreboard (a player may be compared against themself).
Print q lines. For the i-th claim, print true if leftName's score compares to rightName's score as op states, and false otherwise.
1 <= n <= 1000-10^9 <= value <= 10^91 <= q <= 1000Example 1
Input
3 nova 42 zed 17 kip 42 3 nova > zed nova = kip kip < zed
Expected
true true false
Explanation
nova has 42 points, zed has 17, and kip has 42. Claim 'nova > zed' checks 42 > 17, which is true. Claim 'nova = kip' checks 42 = 42, which is true. Claim 'kip < zed' checks 42 < 17, which is false.
Example 2
Input
1 solo 5 2 solo = solo solo > solo
Expected
true false
Explanation
There is only one player, solo, with a score of 5. Comparing solo against themself: 'solo = solo' checks 5 = 5, which is true. 'solo > solo' checks 5 > 5, which is false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →