Intel Code Challenge Elimination Round (Div. 1 + Div. 2, combined)
E
Research Rover
Codeforces
2900
原题
← DF →
翻译中…

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 image.

翻译中…

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.

翻译中…

Input

翻译中…

The first line of the input contains four integers $*n*$, $*m*$, $*k*$ and $*s*$ ($1 ≤ *n*, *m* ≤ 100 000$, $0 ≤ *k* ≤ 2000$, $1 ≤ *s* ≤ 1 000 000$) — 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.

翻译中…

Output

翻译中…

The answer can always be represented as an irreducible fraction image. Print the only integer $*P*·*Q*^{ - 1}$ modulo $10^{9} + 7$.

翻译中…

Note

翻译中…

In the first sample, the rover picks one of the following six routes:

翻译中…
  1. image, after passing cell $(2, 3)$ charge is equal to $6$.
  2. image, after passing cell $(2, 3)$ charge is equal to $6$.
  3. image, charge remains unchanged and equals $11$.
  4. image, after passing cells $(2, 1)$ and $(2, 3)$ charge equals $6$ and then $3$.
  5. image, after passing cell $(2, 1)$ charge is equal to $6$.
  6. image, after passing cell $(2, 1)$ charge is equal to $6$.
翻译中…

Expected value of the battery charge is calculated by the following formula:

翻译中…

image.

翻译中…

Thus $*P* = 19$, and $*Q* = 3$.

翻译中…

$3^{ - 1}$ modulo $10^{9} + 7$ equals $333333336$.

翻译中…

$19·333333336 = 333333342 (*mod* 10^{9} + 7)$

翻译中…

样例

Input #1
3 3 2 11
2 1
2 3
Output #1
333333342
InputCopy OutputCopy
Input #2
4 5 3 17
1 2
3 3
4 1
Output #2
514285727
InputCopy OutputCopy
Input #3
1 6 2 15
1 1
1 5
Output #3
4
InputCopy OutputCopy
题目信息
题号
722E
时间限制
2.5 s
内存限制
256 MB
标签
组合数学
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。