Snuke's Coloring 2-1
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的更多相关文章
- [Arc063F] Snuke's Coloring 2
[Arc063F] Snuke's Coloring 2 题目大意 给你一个网格图,一些点上有标记,求边长最大空白矩形. 试题分析 专门卡\(\log^2 n\)系列. 首先由题意我们可以找到答案的下 ...
- 【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 ...
- すぬけ君の塗り絵 / Snuke's Coloring AtCoder - 2068 (思维,排序,贡献)
Problem Statement We have a grid with H rows and W columns. At first, all cells were painted white. ...
- AtCoder Regular Contest 063 F : Snuke’s Coloring 2 (线段树 + 单调栈)
题意 小 \(\mathrm{C}\) 很喜欢二维染色问题,这天他拿来了一个 \(w × h\) 的二维平面 , 初始时均为白色 . 然后他在上面设置了 \(n\) 个关键点 \((X_i , Y_i ...
- 2018.09.22 atcoder Snuke's Coloring 2(线段树+单调栈)
传送门 就是给出一个矩形,上面有一些点,让你找出一个周长最大的矩形,满足没有一个点在矩形中. 这个题很有意思. 考虑到答案一定会穿过中线. 于是我们可以把点分到中线两边. 先想想暴力如何解决. 显然就 ...
- 2018.09.19 atcoder Snuke's Coloring(思维题)
传送门 谁能想到这道题会写这么久. 本来是一道很sb的题啊. 就是每次选一个点只会影响到周围的九个方格,随便1e9进制就可以hash了,但是我非要作死用stl写. 结果由于技术不够高超,一直调不出来. ...
- [arc063F]Snuke's Coloring 2-[线段树+观察]
Description 传送门 Solution 我们先不考虑周长,只考虑长和宽. 依题意得答案下限为max(w+1,h+1),并且最后所得一定是个矩形(矩形内部无点). 好的,所以!!!答案一定会经 ...
- ARC063F すぬけ君の塗り絵 2 / Snuke's Coloring 2
题面 一句话题面:给你一些点,求这些点之中夹的最大的矩形周长.(考虑边界) Solution 首先是一个结论,答案矩形一定经过\(x=\frac{w}{2}\)或经过\(y=\frac{h}{2}\) ...
- [atARC063F]Snuke's Coloring 2
首先,可以通过将所有$x_{i}=0$都选择第1类,其余选第2类,构造出一个以$(0,0)$和$(1,h)$为左下角和右上角的矩形,答案即为$2h+2$,类似地还可以构造出$2w+2$ 若最终的矩形不 ...
随机推荐
- apache 二级域名设置
1. 你要拥有一个有泛域名解析的顶级域名,例如:test.com 在dns服务上设置,域名服务商都提供此服务 www.test.com 指向服务器IPtest.com 指向 ...
- IE的css hack
#element { color:orange; } #element { *color: white; } /* IE6+7, doesn’t work in IE8/9 as IE7 */ #el ...
- Spark On Yarn搭建及各运行模式说明
之前记录Yarn:Hadoop2.0之YARN组件,这次使用Docker搭建Spark On Yarn 一.各运行模式 1.单机模式 该模式被称为Local[N]模式,是用单机的多个线程来模拟Spa ...
- 我的reshape观
reshape(1,2)把结果分成1块,每一块2个元素 reshape(2,1)把结果分成2块,每一块1个元素 reshape(-1,1)把结果分成任意块,每一块1个元素 reshape(1,-1)把 ...
- 虚拟机kali Linux 的网络配置
首先打开虚拟机中的kali 发现是没有办法连网的 然后我们将kaili关闭 然后打开 然后看黄色区域选择桥接模式然后重新启动即可 https://jingyan.baidu.com/article/7 ...
- bugku 前女友
首先打开链接然后会发现 照常情况下进行分析 查看源码然后发现 在这一串文字后还有一个链接然后 发现链接被隐藏了然后我们将link 删除就会显示出来点开新的连接 然后会发现这个 (仔细一看好像是php中 ...
- Codeforces Round #599 (Div. 2) C. Tile Painting
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to ...
- Nuxt的路由动画效果
Nuxt.js提供两种方法为路由提供动画效果,一种是全局的,一种是针对单独页面的 全局动画默认使用page来进行设置,例如现在我们为每个页面都设置一个进入和退出时的渐隐渐现的效果.我们可以先在根目录的 ...
- Java - Java IO 示例
1. 概述 面试偶尔会问到让你写 文件读写 的面试官 我搞不懂为啥必须会这玩意 面试官的意思是, 这玩意只要是个开发就得会 当然我现在又不是开发 一些概念 读与写 参照 以 进行读写行为的程序 作为参 ...
- 【PAT甲级】1112 Stucked Keyboard (20分)(字符串)
题意: 输入一个正整数K(1<K<=100),接着输入一行字符串由小写字母,数字和下划线组成.如果一个字符它每次出现必定连续出现K个,它可能是坏键,找到坏键按照它们出现的顺序输出(相同坏键 ...