WordCompositionGame
SRM 255 · 2005-07-28 · by Andrew_Lazarev
Problem Statement
Three players are playing a game of word composition in which each player writes down a list of words. After the time expires the scores are calculated using the following rules. Each player gains 3 points for each unique word that only he has, 2 points for each word that is shared with exactly one other player, and 1 point for each word that is shared with both of the other players.
You will be given
Constraints
- listA, listB and listC will have between 1 and 50 elements each, inclusive.
- Each element of listA, listB and listC will contain between 1 and 20 characters, inclusive.
- Each element of listA, listB and listC will contain only lowercase letters ('a'-'z').
- All elements in listA will be distinct.
- All elements in listB will be distinct.
- All elements in listC will be distinct.
{"cat", "dog", "pig", "mouse"}
{"cat", "pig"}
{"dog", "cat"}
Returns: "8/3/3"
{"mouse"}
{"cat", "pig"}
{"dog", "cat"}
Returns: "3/5/5"
{"dog", "mouse"}
{"dog", "pig"}
{"dog", "cat"}
Returns: "4/4/4"
{"bcdbb","aaccd","dacbc","bcbda","cdedc","bbaaa","aecae"}
{"bcdbb","ddacb","aaccd","adcab","edbee","aecae","bcbda"}
{"dcaab","aadbe","bbaaa","ebeec","eaecb","bcbba","aecae","adcab","bcbda"}
Returns: "14/14/21"
{"baacd","aaebe","dbacc","aaeca","aacdd","eacdb","eddce","acabd"}
{"aaebe","eaeac","adbda","bcedc","eddce","abcac","aaabc","deaab","acabc","dccce"}
{"dbdad","deaab","aacdd","aacce","acabc","eacdb","bedba","aaebe","abcac","ccbec"}
Returns: "19/24/23"
Submissions are judged against all 56 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class WordCompositionGame with a public method string score(vector<string> listA, vector<string> listB, vector<string> listC) · 56 test cases · 2 s / 256 MB per case