编程介的小学生 2019-06-25 22:12 采纳率: 20.5%
浏览 138

一种牌面游戏的计算可行性问题,怎么使用C语言的程序的编写的设计的技术来实现这个问题

Military Game is a little funny game that can be found as early as 1882. It was (last) popularized by Martin Gardner in 1963. The game is played by two players as thrown in Figure 1, one controlling the three black pieces while the other controls the remaining red piece. The players alternate to move their pieces, the Red piece can move to any adjacent cell, the Black pieces can only move 'up' or 'sideways', but can not go in a backward (downward) direction. Black wins by trapping Red so that the Red piece can not move, shown as Figure 2. Red wins by either escaping to the bottom cell, or if Black makes 10 passive (non-advancing) moves in a row. Initially, the pieces are placed as Figure 3, and Black goes first. Your task is given a configuration of the game, then determine whether Black has a winning strategy.

Figure 1
Military Game Figure 2
Red is trapped Figure 3
Initial Configuration Figure 4
Cell Index
Input

The input consists of multiple lines, and each represents a game configuration in the format "R B1 B2 B3 T", where R, B1, B2 and B3 are the cell indices as shown in Figure 4 specifying the position of the Red piece and the Black pieces, respectively, and T is a character which is either 'r' or 'b' specifying next player to move the pieces, 'r' for Red and 'b' for Black. The input ends with EOF.

Output

For each game configuration, print a single line to describe whether Black has a winning strategy, if Black can always trap the Red starting from the configuration, print out "Win", and if the Red the can escape, then print out "Lose". You may assume the game never draws according to the rule. If the given configuration is not reachable from the initial configuration, print out "Impossible".

Sample Input

1 2 3 4 r
1 2 6 4 b
1 2 3 6 r
6 8 11 10 b
6 8 9 10 r
1 2 4 4 b
11 11 10 9 b

Sample Output

Win
Win
Lose
Win
Win
Impossible
Impossible

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 易语言把MYSQL数据库中的数据添加至组合框
    • ¥20 求数据集和代码#有偿答复
    • ¥15 关于下拉菜单选项关联的问题
    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况