编程介的小学生 2017-03-23 10:59 采纳率: 20.5%
浏览 780
已采纳

Tower Defense

Tower Defense(TD) is a kind of rpg game in the warcraft3, which is very popular. in this game, you can build some tower near the road, and the enemy come along the road. when the enemy in the tower's attack range, the tower can attack the enemy. and each attack the enemy's life will reduce as the damage of the tower. When the enemy's life less than or equals 0, it dies. The mission of TD is kill all the enemies.

Now let's consider an easy situation. In the X-Y reference frame, there are n towers, each has a coordinate (x,y), an attack range, an attack type. m enemies come from (0,0) to (-10,0), in a line, with the length 2, and the enemies are come one by one. For example, in time 0 the all m enemies in (0,0), then in time 1 the first enemy go to (-2,0), in time 2 the first enemy go to (-4,0), the second enemy go to (-2,0), and so on, when an enemy go to (d,0)(d<=-10), we failed, even if it is still poisoned at this time, or we succeed. when the eneny in (0,0) and (d,0)(d<=-10), the tower can not attack, even if the enemy is in the tower's attack range. To simplify the problem, at each time each tower can attack once. when more than one enemy in its range, we can control it to attack any one, or even control it not attack, with the best strategy.

There are three attack type:
common attack: when an enemy is attacked, the life is reduced by the damage of the tower.
poison attack: when an enemy is attacked, the life is first reduced by the damage of the tower. And in the next 2 times, the enemy's life will be reduced by the poison damage. if the enemy poisoned more than once, the damage will not double. For example, the enemy's life is 200, tower's damage is 100, poison damage is 20, in time 1, the enemy be attacked, then in time 1, the enemy's life is 100(200-100), in time 2 the enemy's life is 80(100-20), in time 3 the enemy's life is 60(100-20).
freezing attack: when an enemy is attacked, the life is first reduced by the damage of the tower. And in next 2 times, the enemy's speed is reduced by half. For example, an enemy be attacked in (-2,0), then it first go to (-3,0), (-4,0), then go to (-6,0), the freezing can not double, too. The problem is give us n towers and m enemies, can we successful in the tower defense?

Input:

The first line of the input is n, m,life and poison_damage, the number of the towers, the number of the enemies, the life of enemy and the poison damage of poison attack. n<6, m<6, life<1000, 0<poison_damage<1000. Next n lines is the description of each tower, the first 5 number is x, y, range, damage, attack_type, the attack_type can be 0, 1, 2, which denote common attack, poison attack, freezing attack. 0<damage<1000. All are integers. a line with n=m=life=0 denoted the end of input.

Output:

If we succeed in the tower defense, output "succeed", or output "fail", in a separate line.

Sample Input:
1 1 10 5
1 1 20 10 0
1 1 20 5
-2 0 1 10 0
2 2 40 5
-3 0 1 30 0
-7 0 1 10 0
0 0 0 5
Sample Output:
succeed
fail
succeed

  • 写回答

2条回答 默认 最新

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

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置