CF1063B.Labyrinth

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are playing some computer game. One of its levels puts you in a maze consisting of nn lines, each of which contains mm cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row rr and column cc . 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 xx times and move right no more than yy 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?

输入格式

The first line contains two integers nn , mm ( 1<=n,m<=20001<=n,m<=2000 ) — the number of rows and the number columns in the labyrinth respectively.

The second line contains two integers rr , cc ( 1<=r<=n1<=r<=n , 1<=c<=m1<=c<=m ) — index of the row and index of the column that define the starting cell.

The third line contains two integers xx , yy ( 0<=x,y<=1090<=x,y<=10^{9} ) — the maximum allowed number of movements to the left and to the right respectively.

The next nn lines describe the labyrinth. Each of them has length of mm and consists only of symbols '.' and '*'. The jj -th character of the ii -th line corresponds to the cell of labyrinth at row ii and column jj . Symbol '.' denotes the free cell, while symbol '*' denotes the cell with an obstacle.

It is guaranteed, that the starting cell contains no obstacles.

输出格式

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:

.++.
.+*.
.++.
.++.
首页