2471. Musical Chair

单点时限: 2.0 sec

内存限制: 256 MB

In the game of Musical Chairs, $n$ players walk around a circle of $n-1$ chairs while music plays on the stereo. When the music stops, everyone hurries to claim a chair. The player who is left standing gets knocked out of the game.

You are given a playerNames-list which containing the names of the players, ordered according to their position at the start of the game, such as the following.

“Emma Sue”, “Billy Bob Thornton”, “Joe”, “Cassius Clay”

You are also given a string chairs describing the arrangement of chairs with an h (lowercase letter H) for each chair and exactly one . (period) indicating a gap. The $i$-th character of chairs corresponds to the $i$-th element of playerNames. For instance, the chairs might be arranged as follows.

hh.h

The player by the gap is the one who gets knocked out. For example, if the four players above are in their starting order when the music stops, then Joe gets knocked out. For each second of music, the players advance one position. From the original order shown above, for example, the players’ order changes to the following after one second.

“Cassius Clay”, “Emma Sue”, “Billy Bob Thornton”, “Joe”

Given an int seconds specifying the number of seconds that the music is played, return the name of the player who gets knocked out.

输入格式

There may be multiple testcase. Process till the end of file.

Each data set start with a single number stand for the number $N$ ($2 \le N \le 50$) of playerNames.

Then following $N$ lines. In each line there is a string stand for one people’s name in the order discribe above.Each element of playerNames will contain between $1$ and $50$ characters, inclusive, and contain only letters (‘A’-‘Z’, ‘a’-‘z’) and spaces (‘ ‘).

$N+2$ line is the string of chairs, it will contain the same number of characters as the number of elements in playerNames. Exactly one character in chairs will be ., and all the other characters will be h.

$N+3$ line is an interger seconds, will be between $0$ and $600$, inclusive.

输出格式

For each test case output a single line, the name of the player who gets knocked out.

There are no extra blank lines between testcases.

样例

Input
4
Emma Sue
Billy Bob Thornton
Joe
Cassius Clay
hh.h
1
4
Emma Sue
Billy Bob Thornton
Joe
Cassius Clay
hh.h
4
6
Jack Dempsey
Joe Louis
Rocky Marciano
Cassius Clay
George Foreman
Mike Tyson
h.hhhh
500
Output
Billy Bob Thornton
Joe
Mike Tyson

33 人解决,38 人已尝试。

47 份提交通过,共有 147 份提交。

4.0 EMB 奖励。

创建: 13 年,7 月前.

修改: 4 年,8 月前.

最后提交: 6 月,2 周前.

来源: Topcoder

题目标签