CF540C.Ice Cave
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.
The level of the cave where you are is a rectangular square grid of n rows and m columns. Each cell consists either from intact or from cracked ice. From each cell you can move to cells that are side-adjacent with yours (due to some limitations of the game engine you cannot make jumps on the same place, i.e. jump from a cell to itself). If you move to the cell with cracked ice, then your character falls down through it and if you move to the cell with intact ice, then the ice on this cell becomes cracked.
Let's number the rows with integers from 1 to n from top to bottom and the columns with integers from 1 to m from left to right. Let's denote a cell on the intersection of the r-th row and the c-th column as (r, c).
You are staying in the cell (_r_1, _c_1) and this cell is cracked because you've just fallen here from a higher level. You need to fall down through the cell (_r_2, _c_2) since the exit to the next level is there. Can you do this?
你正在玩一款电脑游戏。你的角色站在一个多层冰洞的某一层上。为了继续前进,你需要下降到更低的一层,而唯一的方法是坠穿冰面。
你当前所在的洞穴层是一个 n 行 m 列的矩形方格网格。每个格子要么是完好的冰,要么是已出现裂纹的冰。从每个格子出发,你可以移动到与之四连通(即上下左右相邻)的格子(由于游戏引擎的某些限制,你无法原地跳跃,即不能从一个格子跳到它自身)。如果你移动到一个有裂纹的冰的格子上,则你的角色会从此处坠落;如果你移动到一个完好的冰的格子上,则该格子上的冰会变为有裂纹。
我们用从上到下编号为 1 至 n 的整数标记行,用从左到右编号为 1 至 m 的整数标记列。记第 r 行与第 c 列相交的格子为 (r,c)。
你当前位于格子 (r1,c1),且该格子已有裂纹(因为你刚从更高一层坠落至此)。你需要通过格子 (r2,c2) 坠落,因为通往下一层的出口就在此处。你能做到吗?
输入格式
The first line contains two integers, n and m (1 ≤ n, m ≤ 500) — the number of rows and columns in the cave description.
Each of the next n lines describes the initial state of the level of the cave, each line consists of m characters "." (that is, intact ice) and "X" (cracked ice).
The next line contains two integers, _r_1 and _c_1 (1 ≤ _r_1 ≤ n, 1 ≤ _c_1 ≤ m) — your initial coordinates. It is guaranteed that the description of the cave contains character 'X' in cell (_r_1, _c_1), that is, the ice on the starting cell is initially cracked.
The next line contains two integers _r_2 and _c_2 (1 ≤ _r_2 ≤ n, 1 ≤ _c_2 ≤ m) — the coordinates of the cell through which you need to fall. The final cell may coincide with the starting one.
第一行包含两个整数 n 和 m(1≤n,m≤500),分别表示洞穴描述的行数与列数。
接下来的 n 行每行描述洞穴某一层的初始状态,每行由 m 个字符组成,其中 "." 表示完好的冰面,"X" 表示已开裂的冰面。
下一行包含两个整数 r1 和 c1(1≤r1≤n,1≤c1≤m),表示你的初始坐标。保证洞穴描述中位置 (r1,c1) 处的字符为 'X',即起始位置的冰面初始时已开裂。
再下一行包含两个整数 r2 和 c2(1≤r2≤n,1≤c2≤m),表示你需要坠落穿过的单元格坐标。终点单元格可能与起始单元格重合。
输出格式
If you can reach the destination, print 'YES', otherwise print 'NO'.
如果可以到达目的地,输出“YES”,否则输出“NO”。
输入输出样例
输入#1
4 6 X...XX ...XX. .X..X. ...... 1 6 2 2
输出#1
YES
输入#2
5 4 .X.. ...X X.X. .... .XX. 5 3 1 1
输出#2
NO
输入#3
4 7 ..X.XX. .XX..X. X...X.. X...... 2 2 1 6
输出#3
YES
说明/提示
In the first sample test one possible path is:

After the first visit of cell (2, 2) the ice on it cracks and when you step there for the second time, your character falls through the ice as intended.
在第一个样例测试中,一种可能的路径是:

首次访问单元格 (2,2) 后,其上的冰面出现裂痕;当你第二次踏足该单元格时,角色便会按预期坠入冰层之下。
输入解题思路,AI测评打分。不知道怎么写?