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$ 若最终的矩形不 ...
随机推荐
- Go网络编程UDP
package main import ( "fmt" "net" "strings" ) // UDP server func main( ...
- Func<T,TResult>代理
.NET平台已经发生了很多变化,最近决定好好的系统的学习一下了,开发做了这么多年,老实说很多时候都是在吃老本,这样下去不行的... 今天学习的是Func<T,TResult>,它是新的委托 ...
- vue工程 使用滚动组件 vue2-better-scroll 实现上拉加载 下拉刷新
vue2-better-scroll 关于具体安装&使用过程 请移步api文档 已经很详细了 而且超清晰明了. https://cnpmjs.org/package/vue2-better-s ...
- maven一直加载2.0.0.M7 的 config server 失败
之前学习的时候使用F版的SpringBoot管理项目依赖一直好好的,今天不知idea为何抽疯,一直加载失败,各种重启,清除,没用 只能像之前学习注册consul 时将F版的SpringBoot 改为G ...
- Spring Boot 2.x基础教程:找回启动日志中的请求路径列表
如果您看过之前的Spring Boot 1.x教程,或者自己原本就对Spring Boot有一些经验,或者对Spring MVC很熟悉.那么对于Spring构建的Web应用在启动的时候,都会输出当前应 ...
- Redis01——Redis介绍
1.NoSQL数据库概述 NoSQL(NoSQL = Not Only SQL ),意即“不仅仅是SQL”,泛指非关系型的数据库. NoSQL 不依赖业务逻辑方式存储,而以简单的key-value模式 ...
- WSUS补丁服务器部署详细
利用WSUS部署更新程序 来源于网络转载 WSUS概述 为了让用户的windows系统与其他microsoft产品能够更安全,更稳定,因此microsoft会不定期在网站上推出最新的更新程序供用户下 ...
- 空字符串(“”)和null和空格字符串(" ")的区别
1.类型 null表示的是一个对象的值,而并不是一个字符串.例如声明一个对象的引用,String a = null ;""表示的是一个空字符串,也就是说它的长度为0,但它是一个字符 ...
- 「题解」「CF468D」树中的配对
目录 题目大意 思路 源代码 本博客除代码之外,来自 skylee 大佬. 题目大意 一棵\(n(n\le10^5)\)个编号为\(1\sim n\)的点的带边权的树,求一个排列\(p_{1\sim ...
- Python实验案例
Python 运算符.内置函数 实验目的: 1.熟练运用 Python 运算符. 2.熟练运用 Python 内置函数.实验内容: 1.编写程序,输入任意大的自然数,输出各位数字之和. 2.编写程序, ...