1056: Fun Game
内存限制:128 MB
时间限制:3.000 S
评测方式:文本比较
命题人:
提交:7
解决:4
题目描述
A few kids are standing around an old tree playing a game. The tree is so huge that each kid can only see the kids close to him/her.
The game consists many ‘turns’. At the beginning of each turn of the game, a piece of paper is given to a randomly chosen kid. This kid writes the letter “B” if he is a boy or the letter “G” if a girl. Then he chooses a direction to pass the paper (clockwise or counter-clockwise), and gives the paper to his neighbor in that direction. The kid getting the paper writes down his sex too, and gives the paper to his neighbor in the same direction. In this way, the paper goes through the kids one by one, until one kid stops passing the paper and announces the end of this turn.
For example, there are five kids around the tree, and their genders are shown in Figure-1. The paper first goes to Kid1, after writing a “B” he passes it to Kid2, and Kid2 to Kid3. After Kid3 writes down a “G”, she ends up this turn, and we get the paper with a string “BBG”.