A. Orchestra
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Examples
Input
2 2 1 1
1 2
Output
4
Input
3 2 3 3
1 1
3 1
2 2
Output
1
Input
3 2 3 2
1 1
3 1
2 2
Output
4
Note

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

In the first sample, the orchestra looks as follows

*#
**

Paul can take a photograph of just the viola, the 1 × 2 column containing the viola, the 2 × 1 row containing the viola, or the entire string section, for 4 pictures total.

In the second sample, the orchestra looks as follows

#*
*#
#*

Paul must take a photograph of the entire section.

In the third sample, the orchestra looks the same as in the second sample.

题意: r*c的矩阵  n个位置特殊 并给出坐标  问能取多少个子矩阵使得其中特殊位置的个数最小为k

题解: 暴力 矩阵最多10*10  子矩阵 数量很小   (水)

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
using namespace std;
int r,c,n,k;
int mp[][];
int main()
{
scanf("%d %d %d %d",&r,&c,&n,&k);
for(int i=; i<=n; i++)
scanf("%d %d",&mp[i][],&mp[i][]);
int re=;
for(int i=; i<=r; i++)
{
for(int j=; j<=c; j++)
{
for(int kk=i; kk<=r; kk++)
{
for(int g=j; g<=c; g++)
{
int jishu=;
for(int m=; m<=n; m++)
{
if(mp[m][]<=kk&&mp[m][]>=i&&mp[m][]<=g&&mp[m][]>=j)
jishu++;
}
if(jishu>=k)
re++;
}
}
}
}
printf("%d\n",re);
return ;
}

8VC Venture Cup 2016 - Final Round (Div. 2 Edition) A的更多相关文章

  1. 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)

    暴力 A - Orchestra import java.io.*; import java.util.*; public class Main { public static void main(S ...

  2. 8VC Venture Cup 2016 - Final Round (Div. 1 Edition) E - Preorder Test 树形dp

    E - Preorder Test 思路:想到二分答案了之后就不难啦, 对于每个答案用树形dp取check, 如果二分的值是val, dp[ i ]表示 i 这棵子树答案不低于val的可以访问的 最多 ...

  3. 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) D. Factory Repairs 树状数组

    D. Factory Repairs 题目连接: http://www.codeforces.com/contest/635/problem/D Description A factory produ ...

  4. 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) C. XOR Equation 数学

    C. XOR Equation 题目连接: http://www.codeforces.com/contest/635/problem/C Description Two positive integ ...

  5. 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)B. sland Puzzle 水题

    B. sland Puzzle 题目连接: http://www.codeforces.com/contest/635/problem/B Description A remote island ch ...

  6. 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 orches ...

  7. Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition) E - Nikita and stack 线段树好题

    http://codeforces.com/contest/760/problem/E 题目大意:现在对栈有m个操作,但是顺序是乱的,现在每输入一个操作要求你输出当前的栈顶, 注意,已有操作要按它们的 ...

  8. Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition) D - Travel Card

    D - Travel Card 思路:dp,类似于单调队列优化. 其实可以写的更简单... #include<bits/stdc++.h> #define LL long long #de ...

  9. Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition)A 水 B 二分 C并查集

    A. Petr and a calendar time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

随机推荐

  1. php导出excel表格的使用

    网站后台有很多列表数据,常常都会有导出excel表格的需求,和大家分享一个实用的导出excel表格方法: 不多说,上代码: /** * @param array $data 要导出的数据 * @par ...

  2. 牛客练习赛26:D-xor序列(线性基)

    链接:牛客练习赛26:D-xor序列(线性基) 题意:小a有n个数,他提出了一个很有意思的问题:他想知道对于任意的x, y,能否将x与这n个数中的任意多个数异或任意多次后变为y 题解:线性基 #inc ...

  3. 181. Flip Bits【LintCode, by java】

    Description Determine the number of bits required to flip if you want to convert integer n to intege ...

  4. Python入门(3)

    一.列表 列表是用来储存和处理多个数据的数据类型,我们可以像下面这样来创建一个列表: my_list = [1, 2, 3] 列表和数学中的集合很像,但是,列表中的数据是可以重复,并且他们是有序的,列 ...

  5. 基于Kubernetes(k8s)网络方案演进

    VIP PaaS在接近两年时间里,基于kubernetes主要经历四次网络方案的变迁: 1. kubernetes + flannel 2. 基于Docker libnetwork的网络定制 3. k ...

  6. codeforces 295C Greg and Friends(BFS+DP)

    One day Greg and his friends were walking in the forest. Overall there were n people walking, includ ...

  7. 拷贝构造函数 & 拷贝赋值运算符

    一.拷贝构造函数 1. 形式 class A { public: // ... A(const A &); // 拷贝构造函数 }; 2. 合成拷贝构造函数 编译器总会为我们合成一个拷贝构造函 ...

  8. this指针与const成员函数

    this指针的类型为:classType *const      // 即指向类类型非常量版本的常量指针 所以,我们不能把this绑定到一个常量对象上 ===>  不能在一个常量对象上调用普通的 ...

  9. Fafa and the Gates(模拟)

    Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens ...

  10. 给你的WP应用加上帮助文档

    背景 这算是Windows Phone编程回顾续篇, 接着给大家聊WP开发经验. 在开发了数个WP应用并发布后, 陆续收到很多反馈邮件, 其中接近一半的邮件是在问"某某功能有没有?" ...