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 players.  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 and 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
ir3: 2019-09-04 20:00:13

can someone post answer here

rishstage1: 2019-07-16 01:25:29

If a team covers all the nine pawns first, it is the winner irrespective of the red pawn covered or not.

Red pawn just needs to be covered in order to complete the game, so it can be covered either by the losing team or the winning team.

Last edit: 2019-07-16 01:25:40
rayhan50001: 2017-02-21 21:57:48

Nice Problem... :D :D

adi_pra: 2016-10-18 14:57:57

easy question , but language is not proper . After getting 10 WA , finally did it .
Let me clarify this question-
First you have to find which pawns are covered first .
then check which team started first , then some apply your mind .

get_right_jr: 2016-06-07 18:47:07

What a problem! So lengthy!

Last edit: 2016-08-18 13:34:04
hrishabh: 2015-08-02 10:31:42

Nice pblm :)

anuveshkothari: 2015-07-30 19:36:03

hint: use string to check EOF instead of char in c++..

RjlovesS: 2015-03-12 11:40:38

It is to be noted that, red could be won by anyone, not required to be won by the team with all white or all black.

Last edit: 2015-04-07 02:20:24
vikas garg: 2015-01-25 09:06:08

what if team 1 covers all white pawns and team 2 covers 7 black pawns and red one also.. then what shld be the answer????

Vamsi Krishna Avula: 2014-12-28 16:08:33

easily one of my longest codes!
good problem :)


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