There is a rectangle in the xy-plane, with its lower left corner at (0,0) and its upper right corner at (W,H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.

Snuke plotted N points into the rectangle. The coordinate of the i-th (1≤i≤N) point was (xi,yi).

Then, he created an integer sequence a of length N, and for each 1≤i≤N, he painted some region within the rectangle black, as follows:

If ai=1, he painted the region satisfying x

Constraints

1≤W,H≤100

1≤N≤100

0≤xi≤W (1≤i≤N)

0≤yi≤H (1≤i≤N)

W, H (21:32, added), xi and yi are integers.

ai (1≤i≤N) is 1,2,3 or 4.

输入

The input is given from Standard Input in the following format:

W H N

x1 y1 a1

x2 y2 a2

:

xN yN aN

输出

Print the area of the white region within the rectangle after Snuke finished painting.

样例

5 4 2
2 1 1
3 3 4

样例

9

#include <bits/stdc++.h>
using namespace std;
int w,h,n;
int x1,x2,y3,y4;
int ans;
int xx,yy,op;
int main(){
cin >> w >> h >> n;
x2 = w;
y4 = h;
while(n--){
cin >> xx >> yy >> op;
if(op == 1) x1 = max(xx,x1);
else if(op == 2) x2 = min(x2,xx);
else if(op == 3) y3 = max(yy,y3);
else y4 = min(yy,y4);
}
ans = (x2 - x1) * (y4 - y3);
if((x1 >= x2) || (y3 >= y4)) cout << 0;
else cout << ans;
}

Snuke's Coloring 2-1的更多相关文章

  1. [Arc063F] Snuke's Coloring 2

    [Arc063F] Snuke's Coloring 2 题目大意 给你一个网格图,一些点上有标记,求边长最大空白矩形. 试题分析 专门卡\(\log^2 n\)系列. 首先由题意我们可以找到答案的下 ...

  2. 【ARC 063F】Snuke's Coloring 2

    Description There is a rectangle in the xy-plane, with its lower left corner at (0,0) and its upper ...

  3. すぬけ君の塗り絵 / Snuke's Coloring AtCoder - 2068 (思维,排序,贡献)

    Problem Statement We have a grid with H rows and W columns. At first, all cells were painted white. ...

  4. AtCoder Regular Contest 063 F : Snuke’s Coloring 2 (线段树 + 单调栈)

    题意 小 \(\mathrm{C}\) 很喜欢二维染色问题,这天他拿来了一个 \(w × h\) 的二维平面 , 初始时均为白色 . 然后他在上面设置了 \(n\) 个关键点 \((X_i , Y_i ...

  5. 2018.09.22 atcoder Snuke's Coloring 2(线段树+单调栈)

    传送门 就是给出一个矩形,上面有一些点,让你找出一个周长最大的矩形,满足没有一个点在矩形中. 这个题很有意思. 考虑到答案一定会穿过中线. 于是我们可以把点分到中线两边. 先想想暴力如何解决. 显然就 ...

  6. 2018.09.19 atcoder Snuke's Coloring(思维题)

    传送门 谁能想到这道题会写这么久. 本来是一道很sb的题啊. 就是每次选一个点只会影响到周围的九个方格,随便1e9进制就可以hash了,但是我非要作死用stl写. 结果由于技术不够高超,一直调不出来. ...

  7. [arc063F]Snuke's Coloring 2-[线段树+观察]

    Description 传送门 Solution 我们先不考虑周长,只考虑长和宽. 依题意得答案下限为max(w+1,h+1),并且最后所得一定是个矩形(矩形内部无点). 好的,所以!!!答案一定会经 ...

  8. ARC063F すぬけ君の塗り絵 2 / Snuke's Coloring 2

    题面 一句话题面:给你一些点,求这些点之中夹的最大的矩形周长.(考虑边界) Solution 首先是一个结论,答案矩形一定经过\(x=\frac{w}{2}\)或经过\(y=\frac{h}{2}\) ...

  9. [atARC063F]Snuke's Coloring 2

    首先,可以通过将所有$x_{i}=0$都选择第1类,其余选第2类,构造出一个以$(0,0)$和$(1,h)$为左下角和右上角的矩形,答案即为$2h+2$,类似地还可以构造出$2w+2$ 若最终的矩形不 ...

随机推荐

  1. Codeforces 131C . The World is a Theatre(打表组合数)

    题目链接:http://codeforces.com/contest/131/problem/C 大意就是有n个男孩,m个女孩,从男孩中选不少于4个男孩,女孩中选不少于1个女孩,组成人数为t的队伍,问 ...

  2. python测量代码运行时间方法

    Python 社区有句俗语: “python自己带着电池” ,别自己写计时框架. Python3.2具备一个叫做 timeit 的完美计时工具可以测量python代码的运行时间. timeit 模块: ...

  3. (转)JSONObject的toBean 和 fromObject

    public static void main(String[] args) { Map map=new HashMap();map.put("我","妹"); ...

  4. 【visio】故障树分析图

    率属于 商务 故障树是从一个可能的事故开始,自上而下.一层层的寻找顶事件的直接原因和间接原因事件,直到基本原因事件,并用逻辑图把这些事件之间的逻辑关系表达出来. 主要的应用场景:分析复杂问题原因,一个 ...

  5. vue中的回到顶部

    <template> <div class="main"> <div class="content">灰色部分是内容部分&l ...

  6. lightoj 1408 概率dp

    https://blog.csdn.net/moon_sky1999/article/details/98097470 博主在此,牛逼神犇 #include<bits/stdc++.h> ...

  7. KM算法模板 hdu 2255

    KM算法是在匹配是完备的情况下寻找最优匹配. 首先,先将范围定为最大的情况,如果最大的情况无法满足,就下降一个维度继续匹配. 直到匹配成功. #include<cstdio> #inclu ...

  8. linux下修改mysql的编码格式

    修改编码格式:https://blog.csdn.net/qq_30038111/article/details/79376137         改编码格式在配置文件中修改才有效,在命令行中修改没效 ...

  9. vue音乐播放器

    利用vue写一个简单的音乐播放器,包括功能有歌曲搜索.歌曲播放.歌曲封面.歌曲评论.播放动画.mv播放六个功能. <template> <div class="wrap&q ...

  10. 数据库程序接口——JDBC——API解读第一篇——建立连接的核心对象

    结构图 核心对象 Driver Java通过Driver接口表示驱动,每种类型的数据库通过实现Driver接口提供自己的Driver实现类. Driver由属性,操作,事件三部分组成. 属性 公共属性 ...