编程介的小学生 2019-08-24 22:09 采纳率: 20.5%
浏览 91

Queen’s Case用C语言来做

Problem Description
A small country called Maltius was governed by a queen. The queen was known as an oppressive ruler.People in the country suffered from heavy taxes and forced labor. So some young people decided to form a revolutionary army and fight against the queen. Now, they besieged the palace and have just rushed into the entrance.

Your task is to write a program to determine whether the queen can escape or will be caught by the army.

Here is detailed description.
● The palace can be considered as grid squares.
● The queen and the army move alternately. The queen moves first.
● At each of their turns, they either move to an adjacent cell or stay at the same cell.
● Each of them must follow the optimal strategy.
● If the queen and the army are at the same cell, the queen will be caught by the army immediately.
● If the queen is at any of exit cells alone after the army’s turn, the queen can escape from the army.
● There may be cases in which the queen cannot escape but won’t be caught by the army forever,
under their optimal strategies.

Input
The input describes a map of the palace. The first line of the input contains two integers W (1 <= W <= 30) and H (1 <=H <= 30), which indicate the width and height of the palace. The following H lines, each of which contains W characters, denote the map of the palace. “Q” indicates the queen,“A” the army,“E” an exit,“#” a wall and “.” a floor.

The map contains exactly one “Q”, exactly one “A” and at least one “E”. You can assume both the queen and the army can reach all the exits

Output
Output “Queen can escape.”, “Army can catch Queen.” or “Queen can not escape and Army can not catch Queen.” in a line.

Sample Input
2 2
QE
EA
3 1
QAE
3 1
AQE
5 5
..E..
.###.
A###Q
.###.
..E..
5 1
A.E.Q
5 5
A....
####.
..E..
.####
....Q

Sample Output
Queen can not escape and Army can not catch Queen.
Army can catch Queen.
Queen can escape.
Queen can not escape and Army can not catch Queen.
Army can catch Queen.
Army can catch Queen.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作