Submit | All submissions | Best solutions | Back to list |
EIBORROW - Borrow money!!! |
Hang came to Tuan's house to borrow money, but Tuan did not want to lend it to Hang today because she often overdue payments. Taking advantage of her beauty Hang was accepted by Tuan to lend money if she beat Tuan in one of his games. The game is described as follows:
- 2 people play N games together, each game is played on a sequence of cards with the letters 'H' and 'T', 'H' is Hang's card, 'T' is Tuan's card.
- Each game, Tuan is the first, Tuan will peel off 2 adjacent cards to ensure that the 2 cards are arranged in the "HT" order. Hang will then peel 2 adjacent cards in "TH" order. If on Tuan's turn there are not 2 cards next to each other in the order he needs, then Tuan is forced to skip his turn, Hang does the same.
- After 2 cards are dealt, the cards from the back will be brought forward to ensure that the cards are next to each other.
- The game will end when no one can take the cards anymore. The winner will be the person with the most cards left. If the number of Tuan's cards and the number of Hang's cards are equal, no one win . Tuan and Hang both play very well and always peel cards to create the most beneficial situation for themselves.
VD:
THHTTTHHH
1. Tuấn: THHTTTHHH
2. Hằng:THTTHHH
3. Tuấn: (same)
4. Hằng: TTHHH
5. Tuấn: (same)
6. Hằng:THH
Hang win
Input
The first line is an integer N, the number of games Tuan and Hang will play. (1<=N<=100).
Each of the next N lines contains a string of characters T and H. (The length of the string should not exceed 10000 characters).
Output
A line of 2 integers which are the number of games won by Hang and Tuan, respectively.
Example
Input: 2
THH
THHTTTHHH
Output:
2 0
Added by: | Ha Minh Ngoc |
Date: | 2016-09-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |