Submit | All submissions | Best solutions | Back to list |
JESSEGAMBIT - The gambit of Jesse |
During a meeting to prepare for the La Trobe x Monash contest, everyone decided that the best La Trobe competitor will receive a bonus - a date with Jesse. However, things did not go smoothly as Elijah also wanted to date the top 1 of LTU. Therefore, they decided to settle things by playing a game.
The game is set up with n pieces of paper arranged on a circle. The pieces are numbered from 1 to n clockwise. Each of them is either colored red or blue. First, Jesse writes his name in a piece on the circle. Next is Elijah's turn. The two play alternately, from one's turn to the other's. At each turn, the player needs to write his name in an unnamed paper next to another previously marked one.
The game ends when all the pieces on the circle are marked. The person whose name is on more red pieces wins. If the number of red pieces with Elijah and Jesse's name on it are equal to each other, the game ends with a tie.
Since Jesse is the first player and has the right to pick the first piece, help him determine how many ways to select a piece (out of n choices) on the first turn, so that no matter how Elijah plays, Jesse still has a way to win.
Input:
Online line containing n characters (1 <= n <= 20): If the i-th character is R, the piece number i is colored red. If the character is B, the color is blue.
Output:
A single integer which is the answer
Time Limit:
1 second
Example 1:
Input:
RRR
Output:
3
Example 2:
Input:
BRBR
Output:
2
Added by: | LTU ComSoc |
Date: | 2022-03-31 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |