Submit | All submissions | Best solutions | Back to list |
HC - Happy Coins |
A line of coins are given, some belongs to lxh while others belongs to hhb. Now the two guys are about to play a game. In every round of game, each player can select any two consecutive coins and change them into one coin, if the two coins belongs to the same person, the new one will be gained to hhb, or else it will belongs to lxh. The two guys take turns playing this game, lxh always play first. The game runs round by round. You can easily make sense that we will get only one coin at the end of game. Now the question is, suppose the two players perform optimally in the game, which person does the final coin belongs to?
Input
The first line of the input contains one integer T, which indicate the number of test cases.
Following each test, the first line contains an integer N (N ≤ 105), the number of coins. Following N lines, each line contains a name, lxh or hhb, the name of whom this coins belongs to.
Output
For each case, output a line contains the name of whom the final coin belongs to.
Example
Sample Input 1 2 lxh hhb Sample Output lxh
Added by: | Kumar Anurag |
Date: | 2010-06-09 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | TJU |
hide comments
|
||||||
2013-01-14 15:26:30 Titas Skrebė
duhh i put an output line outside the test case loop. dump me :D nice prob. think DP style Last edit: 2013-01-14 15:27:17 |
||||||
2013-01-01 19:09:18 Yo Yo Honey Singh
50th que... :) |
||||||
2012-12-27 09:07:31 gourav
easy one, not able to do 1 month back :-) thank u spoj... 89th |
||||||
2012-10-22 17:41:48 mahaveer
easy problem .... |
||||||
2011-08-29 09:44:03 Problem Solver
@cegprakash, of course not |
||||||
2011-07-08 15:09:18 cegprakash
will there be always even number of coins? |
||||||
2011-06-07 18:48:46 octopus
@ :( :( :( :( ;( ;( :( :( ;( ;( why such a name? |
||||||
2011-03-28 22:19:17 Kunal Kapadia
@Hendra Jaya: No need to cry here for 1 WA.. |
||||||
2011-02-02 22:23:06 TheWarHasBegun
show some other test cases getting WA while my code is giving correct output all the time. |
||||||
2010-10-20 12:07:51 .::Manish Kumar::.
why disco dancer font? |