Losers
SRM 87 · 2002-05-09 · by insomnia
Problem Statement
Create a class Losers that contains a method find which, given a
Notes
- Not all players play each game. A player who does not play in a game gets no score for that game. You need to consider ALL players who have played in at least 1 of the games.
Constraints
- games will contain between 1 and 50 elements, inclusive.
- Valid player names will each be between 1 and 10 capital letters ('A' - 'Z'), inclusive.
- Each element of games will contain at least one name, but need not have more than one player - there need not be a second or third place player.
- Each element of games will be between 1 and 50 characters in length, inclusive.
- Each element of games will be a list of 1 or more valid player names separated by single spaces, with no leading or trailing spaces.
- Each element of games will contain no duplicate names.
- There will not be more than 100 different player names total.
{"BOB FRANK AMY", "BOB AMY FRANK"}
Returns: { "AMY", "FRANK" }
Since BOB has two first places, his score is higher than each of the other two. AMY and FRANK each scored one second place and one third, so they have the same score - and are tied for the worst. Remember to sort the names alphabetically - AMY before FRANK.
{"BOB MIKE DAVE FRANK ART"}
Returns: { "ART", "FRANK" }
Since neither FRANK or ART ever placed in the top 3, they both tie for the worst score. Again, don't forget to sort the names alphabetically.
{"BOB FRANK MIKE JOE ROB"}
Returns: { "JOE", "ROB" }
{"MIKEY DAVE", "DAVE MIKEY"}
Returns: { "DAVE", "MIKEY" }
{"MIKE", "ROB", "AMY"}
Returns: { "AMY", "MIKE", "ROB" }
{"MIKE ROB AMY", "ROB AMY", "ROB AMY"}
Returns: { "MIKE" }
ROB and AMY each have total scores higher than MIKE.
{"A B C", "D B C", "E D C"}
Returns: { "A", "B", "C", "E" }
A and E each have one first place, B has 2 second places, and C has 3 third places - each totalling the same score, and D has a higher score than all the rest of them.
Submissions are judged against all 36 archived test cases, of which 7 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Losers with a public method vector<string> find(vector<string> games) · 36 test cases · 2 s / 256 MB per case