编程介的小学生 2017-02-19 07:15 采纳率: 20.5%
浏览 1030
已采纳

Heroes Of Might And Magic

In the new version of the famous game "Heroes of Might and Magic" heroes themselves take active part in battles. More of that, hero can defeat some monsters alone, without any supporting army. In this problem you are asked to develop the program which would find the strategy for a mage hero fighting face to face with a pack of monsters.
Each hero initially has HP_H hit points and MP_H mana points. Heroes can use different spells. Your hero knows three spells: Lighting Bolt, Teleport and Heal. Each spell costs one mana point.

Each monster has HP_M hit points. Pack of monsters is a single group of several monsters who act as one. Therefore if initially the pack consists of N_M monsters, they have N_M x HP_M hit points. As the battle proceeds, monsters' number of hit points decreases. If monsters have H hit points, that means that the group consists of ceiling(H / HP_M) monsters (ceiling is a function that returns the smallest integer number not less its argument).

The battle runs on a one-dimensional battlefield consisting of N + 1 squares, numbered starting from 0. Your hero resides on the square number 0 and does not move. Monsters initially reside on Nth square and can move. Monsters can move at most V squares a turn.

The battle consists of turns. First your hero makes a turn, then the monsters, and so on. Monsters' strategy is very easy - they move in the direction of your hero min(V, P - 1) squares where P is the square number where they were in the beginning of their turn. If the monsters are on the square number 1 in the end of the movement, then they strike your hero. If there are K monsters left in a pack, their strike decreases hit points of the hero by K. If your hero has non-positive hit points, then the hero is defeated.

Your hero's turn is always the casting of some spell. Lighting Bolt spell removes LP hit points from a pack of monsters, where P is the square number on which the monsters reside. Teleport spell moves monsters to any desired square (except 0 where your hero resides). Heal spell adds dH hit points to hero. However, his hit points never exceed HP_H, so if after using Heal spell his hit points are greater then HP_H, they are decreased to HP_H. If your hero has zero mana points and there is at least one monster left in the pack, then the hero is defeated.

Find the strategy which would allow your hero to defeat monsters. Monsters are defeated if their hit points are non-positive.

Input

The first line of the input file contains positive integer numbers separated by spaces in the following order: N, HP_H, MP_H, HP_M, N_M, V, dH. (1 <= N <= 10, 2 <= HP_H <= 100, 1 <= MP_H <= 50, 1 <= HP_M <= 10, 1 <= N_M <= 10, 1 <= V <= N, 1 <= dH < HP_H). The second line of the input file contains N integer numbers L1, L2, ..., LN (1 <= LP <= 10), separated by spaces.

Process to the end of file.

Output

If the hero cannot win the battle, write the word DEFEATED on the first line of the output file. In the other case write the word VICTORIOUS on the first line of the output file and then write any sequence of hero's actions that leads to victory, where each line of the output file starting from the second one must correspond to one hero's turn. The first character of the line must be one of the following:

L - Cast Lighting Bolt spell.
T - Cast Teleport spell.
H - Cast Heal spell.
If the hero casts Teleport spell then T character must be followed by a space and an integer number from 1 to N - the square number where the monsters should be teleported to.

Sample Input

2 3 2 1 2 1 1
1 1
2 3 2 3 1 1 1
1 1
4 4 3 1 4 1 1
3 1 1 1
1 6 5 1 4 1 3
1

Sample Output

VICTORIOUS
L
L
DEFEATED
VICTORIOUS
L
T 2
L
VICTORIOUS
L
L
H
L
L

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-02-23 15:40
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题