8VC Venture Cup 2016 - Final Round (Div. 2 Edition) A. Orchestra 水题

A. Orchestra

题目连接:

http://www.codeforces.com/contest/635/problem/A

Description

Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least 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.

Input

The first line of input contains four space-separated integers r, c, n, k (1 ≤ r, c, n ≤ 10, 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 lines each contain two integers xi and yi (1 ≤ xi ≤ r, 1 ≤ yi ≤ c): the position of the i-th viola. It is guaranteed that no location appears more than once in the input.

Output

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

Sample Input

2 2 1 1
1 2

Sample Output

4

Hint

题意

有一个r*c的矩阵,然后有n个点是特殊的点

然后问你里面有多少个子矩阵,其中至少有k个特殊的点

题解:

数据范围一看,才10

想怎么做就怎么做,瞎JB做就好了。

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 12;
int a[maxn][maxn];
int r,c,n,k;
int cal(int x,int x1,int y,int y1)
{
    int ans = 0;
    for(int i=x;i<=x1;i++)
        for(int j=y;j<=y1;j++)
            if(a[i][j])ans++;
    return ans;
}
int main()
{
    scanf("%d%d%d%d",&r,&c,&n,&k);
    for(int i=1;i<=n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        a[x][y]=1;
    }
    int ans = 0;
    for(int i=1;i<=r;i++)for(int j=i;j<=r;j++)
    for(int i1=1;i1<=c;i1++)for(int j1=i1;j1<=c;j1++)
    if(cal(i,j,i1,j1)>=k)ans++;
    cout<<ans<<endl;
}
posted @ 2016-03-01 00:07  qscqesze  阅读(283)  评论(0编辑  收藏  举报