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. MySQL在cmd命令行查看端口号

    在命令行输入: show global variables like 'port'; 转自:https://blog.csdn.net/zhufengy/article/details/8014778 ...

  2. idea中使用Data Source and Drivers时,如果使用自己自定义的jar包

  3. 面试题17.打印从1到最大的n位数

    void print_n_number(int n){ if(n<=0){ cout<<"fuckyou"; return; } string s="1 ...

  4. monkey工具使用(未完待续)

    monkey命令详解: 转自:http://blog.csdn.net/jlminghui/article/details/38238443 http://www.cnblogs.com/wfh198 ...

  5. linux用字符模式修改权限

    -rw-r--r--  tt.htm 从第二个字符起rw是说用户apple有读.写权,没有运行权,接着的r--表示用户组users只有读权限,没有运行权,最后的r--指其他人 (others)只有读权 ...

  6. c++调用自己编写的静态库(通过eclipse)

    转:https://blog.csdn.net/hao5335156/article/details/80282829 参考:https://blog.csdn.net/u012707739/arti ...

  7. 【原】shell增加定时任务

    通过shell脚本增加定时任务:#CRON_FILE="/var/spool/cron/root" (centos系统) CRON_FILE="/var/spool/cr ...

  8. 时间类型:datetime,timestamp,date,time,year

    时间类型 1.年月日时分秒:datetime #取值范围# '1000-01-01 00:00:00'到'9999-12-31 23:59:59' 占存储8B:表示的范围比timestamp大:支持0 ...

  9. 每天进步一点点------Alpha半透明图形叠加算法Matlab+Verilog实现

    Alpha图形叠加算法Matlab+Verilog实现 1.1. Alpha算法的研究 Alpha通道是一个8位的灰度通道,该通道用256级灰度来记录图像中的透明度信息,定义透明.不透明和半透明区域, ...

  10. 【Node.js安装步骤】

    "Node.js是一个Javascript运行环境(runtime environment),发布于2009年5月,由Ryan Dahl开发,实质是对Chrome V8引擎进行了封装.本文详 ...