CARRHIM - Can you play carrom !!!


Carrom board is a very popular game. There are four player in this game in dual player mode. In dual player game the team is pair with opposite side player.

 

carrom

 

So, in picture you see the board and the player’s.  Where the player A and the player C in team-1, the player B and the player D in team-2.

In this game a team is play with one color pawn. So, if team-1 start playing the board they take the white pawn, and the team-2 get the black pawn for the game. If team-1 can cover all the pawn before the team-2 and the red also covered by the time then the team-1 will win. Otherwise team-2 will win if they cover their all pawn in the game.

Now, There are 9 white pawn and 9 black pawn and one red pawn in the board. The game is played by different rule.

In my problem of this game the rule like,

The point for the one pawn is 1 and for red is 5.

You can assume that which player 1st start playing  the game is start with the white pawn.one team must cover red pawn and this team will get the red point.And you know the penalty rule is If one player cover one pawn of opposite team then the turn goes to the next player.

Now your task is to find the winner team & points.

The points count by the remaining of pawn in the board and plus the covered red pawn point by the winning team.

 

Input

Input consists of pairs of lines (at most 100 lines). Each pair contains 1 character and 3 integer. A first character is the player id(A , B , C or D) and three integer is W, B, R (1<= W, B<=9) separated by a space that is number of white, black and red pawn the player cover in his turn. The end of one input occurs when the first sequence starts with an "#" character (without the quotes).

 

Output

For each case if the game complete then you have to print a string “Team-1 win and the point is N.” (without the quotes) when team-1 win , Otherwise   “Team-2 win and the point is N.” (without the quotes).

If the game is incomplete then print a string "Incomplete game." (without the quotes) when a team can not cover all the pawn of his turn.

N is the total point of winner team. See the sample input/output for exact formatting.

 

Sample

Input :

A 5 1 0

B 1 2 0

C 2 1 1

D 1 0 0

#

B 1 1 0

C 1 2 0

D 3 1 1

A 1 2 0

B 3 0 0

#

A 1 1 0

B 1 5 1

C 1 1 0

#

Output :

Team-1 win and the point is 10.

Team-2 win and the point is 8.

Incomplete game.

 

Explanation :

For the first input player A start the game so the team-1 play with the white pawn.
After all input the team-1 cover all of white pawn also the red pawn.
and there are 5 black pawn remain in the board.
so, team-1 win and the point is 5+5=10.

____________________________________________________________________________________________________________

 Problem setter: Md. Hashibul Amin Hemel, Dept. of CSE

Bangladesh University of Business and Technology (BUBT)


hide comments
Sachin Railhan: 2013-12-11 11:26:22

What if red is not covered by any team but all white pawns are covered by team 1?
Edit: In my AC solution i assume game to be incomplete if red pawn is not covered by any team.Hope it helps others.

Last edit: 2013-12-11 15:44:40
Bhavik: 2013-10-21 14:51:50

kindly chk my code id:10312435...giving tle after 8 test case!!

EDIT:-AC:)))becomes simpler if you play carrom...difficult for those who have not played this game

Last edit: 2013-10-21 16:25:00
Miguel Oliveira: 2013-09-25 10:14:29

I'm not familiar to the game.
Let's say team 1 plays first. They only win if all white pawns and the red one are covered?
The red needs to be covered by team 1 in order for team 1 to win? Or does team 1 win anyway if the red if covered by team 2, but all white pawns were covered?

What if all black pawns are covered?

Last edit: 2016-08-18 13:34:49

Added by:hemel
Date:2013-09-23
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Own problem