http://codeforces.com/contest/635/problem/A
在一个r*c矩阵 有n个钻石
有多少个不同的子矩阵可以覆盖至少k个钻石。。。数据范围只有10。。。。直接暴力枚举。。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
const double pi=acos(-1.0);
double eps=0.000001;
int mp[15][15];
int sum[15][15];
int main()
{
int i,j,g,h,f;
int x,y,k;
int r,c,n;
cin>>r>>c>>n>>k;
for (i=1;i<=n;i++)
{
scanf("%d%d",&x,&y);
mp[x][y]=1;
}
for (i=1;i<=r;i++)
{
for (j=1;j<=c;j++)
{
sum[i][j]=sum[i-1][j]+mp[i][j];
}
}
int tmp[15];
int ans=0;
for (i=1;i<=r;i++)
{
for (j=i;j<=r;j++)
{
for (h=1;h<=c;h++)
tmp[h]=sum[j][h]-sum[i-1][h];
for (h=1;h<=c;h++)
{
for (g=h;g<=c;g++)
{
int sum=0;
for (f=h;f<=g;f++)
sum+=tmp[f];
if (sum>=k)
ans++;
}
}
}
}
printf("%d\n",ans);
return 0;
}