#P1908. Orchestra

    ID: 1908 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>基础算法枚举模拟前缀和CodeForces

Orchestra

Orchestra

题面翻译

  • 在一个 r×cr \times c 的矩阵中有 nn 个点,问有多少个连续子矩阵至少包含 kk 个点。
  • r,c,n,k10r,c,n,k \le 10

题目描述

Paul is at the orchestra. The string section is arranged in an r×c r×c rectangular grid and is filled with violinists with the exception of n n violists. Paul really likes violas, so he would like to take a picture including at least k k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count the number of possible pictures that Paul can take.

Two pictures are considered to be different if the coordinates of corresponding rectangles are different.

输入格式

The first line of input contains four space-separated integers r r , c c , n n , k k ( 1<=r,c,n<=10 1<=r,c,n<=10 , 1<=k<=n 1<=k<=n ) — the number of rows and columns of the string section, the total number of violas, and the minimum number of violas Paul would like in his photograph, respectively.

The next n n lines each contain two integers xi x_{i} and yi y_{i} ( 1<=xi<=r 1<=x_{i}<=r , 1<=yi<=c 1<=y_{i}<=c ): the position of the i i -th viola. It is guaranteed that no location appears more than once in the input.

输出格式

Print a single integer — the number of photographs Paul can take which include at least k k violas.

样例 #1

样例输入 #1

2 2 1 1
1 2

样例输出 #1

4

样例 #2

样例输入 #2

3 2 3 3
1 1
3 1
2 2

样例输出 #2

1

样例 #3

样例输入 #3

3 2 3 2
1 1
3 1
2 2

样例输出 #3

4

提示

We will use '*' to denote violinists and '#' to denote violists.

In the first sample, the orchestra looks as follows

<br></br>*#<br></br>**<br></br> Paul can take a photograph of just the viola, the 1×2 1×2 column containing the viola, the 2×1 2×1 row containing the viola, or the entire string section, for 4 4 pictures total.In the second sample, the orchestra looks as follows

<br></br>#*<br></br>*#<br></br>#*<br></br> Paul must take a photograph of the entire section.In the third sample, the orchestra looks the same as in the second sample.