Etiquette
SRM 123 · 2002-12-10 · by axchma
Problem Statement
Your task is, given a
Notes
- Gaps between groups are assumed to be long enough. Hence, a gentleman who goes up the stairs later than a lady from a previous group doesn't necessarily count as not being a true gentleman (his status depends on his position relative the ladies in his own group).
Constraints
- people will consist only of the characters 'L', 'G' and ' ' (space)
- people will have between 0 and 50 characters inclusive
"LGG" Returns: 2
"GGL LGG" Returns: 2
"GLL LL GG G GGLL" Returns: 0
"" Returns: 0
"LLL GGG" Returns: 0
"LL GG GLG GGL LG LG GL" Returns: 3
The first two groups consist of people of one gender, so there is no way to check if they know rules, hence we do not count anyone here. In the third group one gentleman doesn't know the exception rule, hence we count one non-true gentleman here. In the fourth group both gentlemen are true gentlemen, so we add zero here. In the fifth the gentleman is not a true gentleman, so we add one. The sixth group is the same as the fifth group, so we add one more. In the last group the gentleman is a true gentleman, so we do not count him.
"L GLGGGGGGGGGG LLGLLL L LLG G G LGG L GL G GL" Returns: 14
ten random test cases
Submissions are judged against all 65 archived test cases, of which 7 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Etiquette with a public method int numNonGent(string people) · 65 test cases · 2 s / 256 MB per case