Connection Status:
Competition Arena > MemberCheck
SRM 136 · 2003-02-25 · by lars2520
Class Name: MemberCheck
Return Type: String[]
Method Name: whosDishonest
Arg Types: (vector<string>, vector<string>, vector<string>)
Problem Statement

Problem Statement

A health club chain allows its members to visit any of its many health club locations an unlimited number of times per day. The only constraining rule is, a customer can only visit one health club location per day, even though he or she may return to that location an unlimited number of times for the rest of that day.

Although the honor system has always worked quite well, the club wants to run some tests to see how many people really follow the rules. You are to write a program that takes the entrance log files from three different clubs (all logging the same day) and return a sorted list of the people who are not honest and went to more than one health club location in the same day.

The log files are represented as String[]'s where each element is the member name of a customer who entered that day. For example, if a customer showed up three times to one of the club locations that day, the member's name would appear three times in the corresponding String[].

Notes

  • club1, club2, and club3 may contain a different number of elements.
  • The same member name can appear multiple times in a single log file.
  • The elements of the returned String[] should be sorted in lexicographic order (the order they would appear in a dictionary).
  • Assume that two people with the same name are in fact the same person.

Constraints

  • club1, club2, and club3 each have between 1 and 50 elements, inclusive.
  • Each element of club1, club2, and club3 contains between 1 and 50 characters, inclusive..
  • Each element of club1, club2, and club3 consists only of uppercase letters ('A'-'Z').
Examples
0)
{"JOHN","JOHN","FRED","PEG"}
{"PEG","GEORGE"}
{"GEORGE","DAVID"}
Returns: { "GEORGE",  "PEG" }

"PEG" went to club1 and club2, and "GEORGE" went to club2 and club3.

1)
{"DOUG","DOUG","DOUG","DOUG","DOUG"}
{"BOBBY","BOBBY"}
{"JAMES"}
Returns: { }

Here, no one went to more than one club location.

2)
{"BOBBY"}
{"BOB","BOBBY"}
{"BOB"}
Returns: { "BOB",  "BOBBY" }

Note that "BOB" is sorted before "BOBBY"

3)
{"BOBBY","HUGH","LIZ","GEORGE"}
{"ELIZABETH","WILL"}
{"BOB","BOBBY","BOBBY","PAM","LIZ","BOBBY","BOBBY","WILL"}
Returns: { "BOBBY",  "LIZ",  "WILL" }
4)
{"JAMES","HUGH","HUGH","GEORGE","ELIZABETH","ELIZABETH","HUGH",
"DAVID","ROBERT","DAVID","BOB","BOBBY","PAM","JAMES","JAMES"}
{"BOBBY","ROBERT","GEORGE","JAMES","PEG","JAMES","DAVID","JOHN","LIZ",
"SANDRA","GEORGE","JOHN","GEORGE","ELIZABETH","LIZ","JAMES"}
{"ROBERT","ROBERT","ROBERT","SANDRA","PAM","BOB","LIZ","GEORGE"}
Returns: { "BOB",  "BOBBY",  "DAVID",  "ELIZABETH",  "GEORGE",  "JAMES",  "LIZ",  "PAM",  "ROBERT",  "SANDRA" }

Submissions are judged against all 43 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class MemberCheck with a public method vector<string> whosDishonest(vector<string> club1, vector<string> club2, vector<string> club3) · 43 test cases · 2 s / 256 MB per case

Submitting as anonymous