#P2154. [SDOI2009] 虔诚的墓主人

    ID: 1132 远端评测题 800ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学2009各省省选树状数组山东排列组合

[SDOI2009] 虔诚的墓主人

Description

Xiao W is the manager of a newly built cemetery. The cemetery can be regarded as an N×MN×M rectangle. Each lattice point is either planted with an evergreen tree, or is a grave plot that has not yet been assigned.

The local residents are very devout Christians, and they are willing to choose a suitable grave plot for themselves in advance. To show their sincerity to the Lord, they hope their grave plot has a high level of piety.

The piety of a grave plot is defined as the number of crosses centered at this plot. A cross consists of a center grave plot, and exactly kk evergreen trees immediately above, below, left, and right of it.

Formally, for a grave plot at coordinates (x,y)(x, y), the number of crosses centered at it is the number of sequences of length 4k4k of ordered pairs $[(x_{1,1},y_{1,1}),\allowbreak(x_{1,2},y_{1,2}),\allowbreak\cdots,(x_{1,k},y_{1,k}),\allowbreak(x_{2,1},y_{2,1}),\allowbreak(x_{2,2},y_{2,2}),\allowbreak\cdots,(x_{2,k},y_{2,k}),\allowbreak(x_{3,1},y_{3,1}),\allowbreak(x_{3,2},y_{3,2}),\allowbreak\cdots,(x_{3,k},y_{3,k}),\allowbreak(x_{4,1},y_{4,1}),\allowbreak(x_{4,2},y_{4,2}),\allowbreak\cdots,(x_{4,k},y_{4,k})]$ that satisfy:

  • Each ordered pair corresponds to the coordinates of an evergreen tree.
  • x1,1<x1,2<<x1,k<xx_{1,1}<x_{1,2}<\cdots< x_{1,k}<x and y1,1=y1,2==y1,k=yy_{1,1}=y_{1,2}=\cdots=y_{1,k}=y.
  • x<x2,1<x2,2<<x2,kx<x_{2,1}<x_{2,2}<\cdots< x_{2,k} and y2,1=y2,2==y2,k=yy_{2,1}=y_{2,2}=\cdots=y_{2,k}=y.
  • y3,1<y3,2<<y3,k<yy_{3,1}<y_{3,2}<\cdots< y_{3,k}<y and x3,1=x3,2==x3,k=xx_{3,1}=x_{3,2}=\cdots=x_{3,k}=x.
  • y<y4,1<y4,2<<y4,ky<y_{4,1}<y_{4,2}<\cdots< y_{4,k} and x4,1=x4,2==x4,k=xx_{4,1}=x_{4,2}=\cdots=x_{4,k}=x.

Xiao W wants to know the sum of the piety levels of all grave plots in the cemetery.

Input Format

The first line contains two positive integers NN and MM, representing the width and length of the cemetery. Therefore, this rectangular cemetery has (N+1)×(M+1)(N+1) ×(M+1) lattice points, with the lower-left corner at (0,0)(0, 0) and the upper-right corner at (N,M)(N, M).

The second line contains a positive integer WW, representing the number of evergreen trees in the cemetery.

From the third line, there are WW lines. Each line contains two non-negative integers xix_i and yiy_i, representing the coordinates of an evergreen tree. The input guarantees that no two evergreen trees have the same coordinates.

The last line contains a positive integer kk, as defined in the statement.

Output Format

Output a single non-negative integer, which is the sum of the piety levels over all grave plots in this cemetery. For convenience, output the answer modulo 2,147,483,6482{,}147{,}483{,}648.

5 6
13
0 2
0 3
1 2
1 3
2 0
2 1
2 4
2 5
2 6
3 2
3 3
4 3
5 2
2
6

Hint

In the figure, the number of crosses centered at grave plots (2,2)(2, 2) and (2,3)(2, 3) is 33, so their piety levels are both 33. The piety level of every other grave plot is 00.

For 30%30\% of the testdata, 1N,M1031 ≤ N, M ≤ 10^3.

For 60%60\% of the testdata, 1N,M1061 ≤ N, M ≤ 10^6.

For 100%100\% of the testdata, 1N,M1091 ≤ N, M ≤ 10^90xiN0 ≤ x_i ≤ N0yiM0 ≤ y_i ≤ M1W1051 ≤ W ≤ 10^51k101 ≤ k ≤ 10

There exists 50%50\% of the testdata such that 1k21 ≤ k ≤ 2.

There exists 25%25\% of the testdata such that 1W1041 ≤ W ≤ 10^4.

Translated by ChatGPT 5