Volleyball Match
InterviewTime limit1sMemory limit1024 MB
Given the winner of each rally, simulate a best-of-3 volleyball match with win-by-2 set rules and print the number of sets each team won.
- Level
Easy2 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Problem
You have been hired by PO-Volley (Påhittade Organisationen för Volleyboll) to keep track of the score in a volleyball match between two teams, Algoritmikerna and Bäverbusarna.
The match is best of sets. The team that first wins sets wins the match. The first two sets are played to points, and if a third set is needed, it is played to points. A team must win by points. So the winner of a set is the first team to reach at least (or in the third set) points while leading the opponent by at least points. Given which team wins each rally, print the result of the match.
Input
The first line contains an integer (). The next line contains a string of characters, each either 'A' or 'B'. The th character is 'A' if Algoritmikerna wins the th rally, and 'B' if Bäverbusarna wins it.
Output
Print one line with two integers. The first integer is the number of sets won by Algoritmikerna, and the second integer is the number of sets won by Bäverbusarna.
Hints
In the first sample, team A wins the first set , team B wins the second set , and team A wins the deciding third set . The result is .
In the second sample, team B wins both the first and second sets , so the result is .
Note that only the first sample could appear in test group .