A8284 | World of Darkraft
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
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.
输出格式
On the first line print "WIN" if Roma can win or "LOSE" if it is impossible to win considering that the opponent pays optimally.
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted