Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: The story of three kingdoms XI
Description Recently, Facer is absorbed in playing “The story of three kingdoms XI”. It is an interesting game but the battle system is so complicated and it always cost much time. In order to fasten the game process, Facer decide to write a auto-play program. It's Facer's turn. Now Facer can control his troops one by one (in any order) and he wants to eliminate as many enemies as possible in his round. The battlefield is a matrix of There are three kinds of troops----Lancers, Halberdiers and Cavaliers. Each kind of troops has an Ability of Movement (AM) and an Ability of Attacking (AA). AM decides how far the troops can go and AA decides the damage of one soldier in the troops. In the process of MOVE, Facer's troops can move up to AM times to adjacent grids in up/left/right/down directions. Troops can go through other Facer's army (considered as non-occupied-grass field) but enemies will block the way (considered as mountains). For example, if Troops A has an AM of 3 then move to any of the BOLD field is legal. (Where F regard as enemy troops and B is one of Facer's army). X O F In the process of ATTACK, Facer's troops can deal some damage to adjacent enemy troops (adjacent in four directions in up/left/right/down). The basic damage equals to number of soldiers in the troops multiply AA of that kind of troops. When use Lancers to attack Cavaliers (represented as Lancers->Cavaliers), the damage will be doubled. This will also happen when Cavaliers->Halberdiers and Halberdiers->Lancers. Enemy troops will lost the same number of soldiers as the final damage point. Note that if the damage point is higher than the rest number of soldiers, the exceeded damage will be wasted. To simplify the question, even if all the soldiers of an enemy troops are lost, the grid is still considered occupied and Facer's troops cannot go through. Now given the information of the battlefield and write a program to decide how many enemy soldiers can be eliminated in Facer's turn. Input There are multiple test cases.For each test case, The first line contains three integers representing the AM of Lancers, AM of Cavaliers and AM of Halberdiers. The second line contains three integers representing the AA of Lancers, AA of Cavaliers and AA of Halberdiers. The third line contains two integers representing The following N lines describe the battlefields. Each line contains Each element could be: 'O'- Non-occupied-Grass field 'X'- Mountains A character in 'A'-'F' and an integer-Occupied grass field ('A' for Facer's Lancers, 'B' for Facer's Cavaliers, 'C' for Facer's Halberdiers, 'D' for Enemy Lancers, 'E' for Enemy Cavaliers, 'F' for Enemy Halberdiers, the integer stands for the number of soldiers in that troops and the integer will be in the range of 1 to 100) A test case starting with three zeros indicates the end of input data. Note that both Facer and his enemy will have up to 10 troops. Output For each test case, output contains only one integer, the maximum number of enemy soldiers Facer can eliminate in his turn. Sample Input 3 3 3 1 1 1 4 4 X A1 A1 X X O O X X D1 D1 X X X X X 0 0 0 Sample Output 2 Source POJ Monthly Contest - 2010.04.04, 1318dotaer |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator