ServiceNames
SRM 336 · 2007-01-25 · by dgoodman
Problem Statement
Given a
Each KindOfInput should appear exactly once in the return. Within each element of the return, the service names should be in alphabetical order, and should be separated by the 2 characters ", " (comma space). The KindOfInput should be separated from the first service name by the 5 characters " ==> " (space eq eq gt space). The returned list should be in alphabetical order.
Note that all names are case-sensitive, and that "alphabetical order" refers to the ASCII ordering, where, for example, 'Z' precedes 'a'.
Constraints
- services will contain between 1 and 50 elements, inclusive.
- Each element of services will contain between 1 and 50 characters, inclusive.
- Each element of services will contain tokens separated by a single space (' ').
- Each token will consist of 1 or more letters ('A'-'Z' or 'a'-'z').
- The first tokens of the elements in services will be distinct.
- Within each element of services the KindsOfInput will be distinct.
{"BLAST Genome Annotation Sensitivity","PING","X Annotation"}
Returns: {"Annotation ==> BLAST, X", "Genome ==> BLAST", "Sensitivity ==> BLAST" }
{"PING"}
Returns: { }
There are no KindsOfInput so the return has 0 elements.
{"BLAST Genome annotation Sensitivity","PING","X Annotation","Apple X ample"}
Returns: {"Annotation ==> X", "Genome ==> BLAST", "Sensitivity ==> BLAST", "X ==> Apple", "ample ==> Apple", "annotation ==> BLAST" }
annotation and Annotation are distinct kinds of input. annotation comes later alphabetically than any name that starts with an uppercase letter.
{"NULL"}
Returns: { }
{"A a","B a","C a","D a"}
Returns: {"a ==> A, B, C, D" }
Submissions are judged against all 85 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ServiceNames with a public method vector<string> makeList(vector<string> services) · 85 test cases · 2 s / 256 MB per case