CF138D.World of Darkraft

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Recently Roma has become the happy owner of a new game World of Darkraft. This game combines elements of virtually all known genres, and on one of the later stages of the game Roma faced difficulties solving a puzzle.

In this part Roma fights with a cunning enemy magician. The battle takes place on a rectangular field plaid n × m. Each cell contains one magical character: L, R or X. Initially all the squares of the field are "active".

The players, Roma and enemy magician, take turns. Roma makes the first move. During a move a player selects one of the active cells. Then depending on the image in the character in the cell one of the following actions takes place:

  • L — magical waves radiate from the cell to the left downwards and to the right upwards along diagonal paths. All cells on the path of the waves (including the selected cell too) become inactive. The waves continue until the next inactive cell or to the edge of the field if there are no inactive cells on the way.
  • R — the magical waves radiate to the left upwards and to the right downwards.
  • X — the magical waves radiate in all four diagonal directions.

If the next player cannot make a move (i.e., all cells are inactive), he loses.

Roma has been trying to defeat the computer opponent for three days but he just keeps losing. He asks you to help him and determine whether it is guaranteed that he can beat the opponent, or he will have to hack the game.

最近,罗玛成为了一款新游戏《暗黑之境》(World of Darkraft)的幸运拥有者。这款游戏融合了几乎所有已知游戏类型的元素,在游戏后期的一个关卡中,罗玛遇到了一个解谜难题。

在此关卡中,罗玛需与一名狡猾的敌方魔法师对战。战斗发生在一个 n×mn \times m 的矩形棋盘上。每个格子中包含一个魔法字符:L、R 或 X。初始时,棋盘上的所有格子均为“活跃”状态。

罗玛与敌方魔法师轮流行动,罗玛先行。在每次行动中,玩家需选择一个当前处于活跃状态的格子;随后,根据该格子中字符的类型,执行以下对应操作:

  • L —— 魔法波从此格子沿两条对角线方向传播:向左下方、向右上方。波所经过的所有格子(包括被选中的格子本身)均变为非活跃状态。波将持续传播,直至遇到第一个非活跃格子,或抵达棋盘边界(若路径上无任何非活跃格子)。
  • R —— 魔法波沿另外两条对角线方向传播:向左上方、向右下方。
  • X —— 魔法波沿全部四条对角线方向传播。

若轮到某位玩家行动时已无活跃格子可选,则该玩家判负。

罗玛已连续三天尝试击败电脑对手,却屡战屡败。他请求你帮助他判断:是否存在必胜策略以确保战胜对手?抑或他只能选择修改游戏程序(即“作弊”)?

输入格式

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 20).

Next n lines contain m characters describing the playing field: the j-th character of the i-th line equals to the magical character of the corresponding field square.

第一行包含两个以空格分隔的整数 nn 和 mm(1 ≤ n, m ≤ 201 \le n, m \le 20)。

接下来的 nn 行,每行包含 mm 个字符,用于描述游戏场地:第 ii 行的第 jj 个字符表示对应方格上的魔法字符。

输出格式

On the first line print "WIN" if Roma can win or "LOSE" if it is impossible to win considering that the opponent pays optimally.

第一行输出“WIN”(如果罗玛能获胜)或“LOSE”(如果在对手采取最优策略的情况下无法获胜)。

输入输出样例

  • 输入#1

    2 2
    RL
    LR

    输出#1

    LOSE
  • 输入#2

    2 2
    RR
    RR

    输出#2

    WIN

说明/提示

In the first test each move makes one diagonal line of the square inactive, thus it is guaranteed that Roma loses after two moves.

There are three variants of making a move in the second test: to "finish off" the main diagonal line or any of the squares that are left. That means that after three moves the game stops and Roma wins.

在第一个测试中,每次移动会使正方形的一条对角线失效,因此保证罗玛在两次移动后失败。

在第二个测试中,有三种移动方式:完成主对角线,或完成任意一个剩余的方格。这意味着经过三次移动后游戏结束,罗玛获胜。

输入解题思路,AI测评打分。不知道怎么写?

首页