CF1063B.Labyrinth
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not occupied by an obstacle. You can't move beyond the boundaries of the labyrinth.
Unfortunately, your keyboard is about to break, so you can move left no more than x times and move right no more than y times. There are no restrictions on the number of moves up and down since the keys used to move up and down are in perfect condition.
Now you would like to determine for each cell whether there exists a sequence of moves that will put you from the starting cell to this particular one. How many cells of the board have this property?
你正在玩一款电脑游戏。游戏的某一关将你置于一个由 n 行组成的迷宫中,每行包含 m 个格子。每个格子要么是空闲的,要么被障碍物占据。起始格子位于第 r 行、第 c 列。每一步,你可以向上、向左、向下或向右移动一格,前提是目标格子未被障碍物占据。你不能移出迷宫边界。
不幸的是,你的键盘即将损坏,因此你向左移动的次数不能超过 x 次,向右移动的次数不能超过 y 次。由于用于上下移动的按键状态完好,因此对向上和向下移动的次数没有任何限制。
现在,你想判断:对于迷宫中的每一个格子,是否存在一条从起始格子出发、到达该格子的合法移动序列。满足这一性质的格子共有多少个?
输入格式
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively.
The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell.
The third line contains two integers x, y (0 ≤ x, y ≤ 109) — the maximum allowed number of movements to the left and to the right respectively.
The next n lines describe the labyrinth. Each of them has length of m and consists only of symbols '.' and '*'. The j-th character of the i-th line corresponds to the cell of labyrinth at row i and column j. Symbol '.' denotes the free cell, while symbol '*' denotes the cell with an obstacle.
It is guaranteed, that the starting cell contains no obstacles.
第一行包含两个整数 n、m(1≤n,m≤2000)—— 分别表示迷宫的行数和列数。
第二行包含两个整数 r、c(1≤r≤n,1≤c≤m)—— 表示起始单元格所在的行索引与列索引。
第三行包含两个整数 x、y(0≤x,y≤109)—— 分别表示向左移动与向右移动的最大允许次数。
接下来的 n 行描述迷宫。每行长度为 m,且仅由字符 . 和 * 组成。第 i 行的第 j 个字符对应迷宫中第 i 行、第 j 列的单元格。字符 . 表示空闲单元格,而字符 * 表示障碍物单元格。
保证起始单元格不含有障碍物。
输出格式
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
输出一个整数——即迷宫中从起始单元格出发可达的单元格数量(包括起始单元格本身)。
输入输出样例
输入#1
4 5 3 2 1 2 ..... .***. ...** *....
输出#1
10
输入#2
4 4 2 2 0 1 .... ..*. .... ....
输出#2
7
说明/提示
Cells, reachable in the corresponding example, are marked with '+'.
First example:
+++..
+***.
+**
*+.
Second example:
..
.+*.
..
.++.
对应示例中可达的单元格用 + 标记。
第一个示例:
+++..
+***.
+++**
*+++.
第二个示例:
.++.
.+*.
.++.
.++.
输入解题思路,AI测评打分。不知道怎么写?