题库练习 Research Rover
← 上一题 下一题 →

A10634 | Research Rover

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Unfortunately, the formal description of the task turned out to be too long, so here is the legend.

Research rover finally reached the surface of Mars and is ready to complete its mission. Unfortunately, due to the mistake in the navigation system design, the rover is located in the wrong place.

The rover will operate on the grid consisting of $n$ rows and $m$ columns. We will define as $(r,c)$ the cell located in the row $r$ and column $c$ . From each cell the rover is able to move to any cell that share a side with the current one.

The rover is currently located at cell $(1,1)$ and has to move to the cell $(n,m)$ . It will randomly follow some shortest path between these two cells. Each possible way is chosen equiprobably.

The cargo section of the rover contains the battery required to conduct the research. Initially, the battery charge is equal to $s$ units of energy.

Some of the cells contain anomaly. Each time the rover gets to the cell with anomaly, the battery looses half of its charge rounded down. Formally, if the charge was equal to $x$ before the rover gets to the cell with anomaly, the charge will change to ![](/uploads/acgo/image/b53d913fe2502585_9ea5f814c1a9.jpeg).

While the rover picks a random shortest path to proceed, compute the expected value of the battery charge after it reaches cell $(n,m)$ . If the cells $(1,1)$ and $(n,m)$ contain anomaly, they also affect the charge of the battery.

输入格式

The first line of the input contains four integers $n$ , $m$ , $k$ and $s$ ( $1<=n,m<=100000$ , $0<=k<=2000$ , $1<=s<=1000000$ ) — the number of rows and columns of the field, the number of cells with anomaly and the initial charge of the battery respectively.

The follow $k$ lines containing two integers $r_{i}$ and $c_{i}$ ( $1<=r_{i}<=n$ , $1<=c_{i}<=m$ ) — coordinates of the cells, containing anomaly. It's guaranteed that each cell appears in this list no more than once.

输出格式

The answer can always be represented as an irreducible fraction ![](/uploads/acgo/image/72ab2484bf3ada2f_d32a37749e7f.jpeg). Print the only integer $P·Q^{-1}$ modulo $10^{9}+7$ .

输入输出样例

输入 #1
3 3 2 11
2 1
2 3
输出 #1
333333342
输入 #2
4 5 3 17
1 2
3 3
4 1
输出 #2
514285727
输入 #3
1 6 2 15
1 1
1 5
输出 #3
4
C++ 编辑器
输入
输出