【CF527C】Glass Carving
【CF527C】Glass Carving
题面
题解
因为横着切与纵切无关
所以开\(set\)维护横着的最大值和纵着的最大值即可
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
inline int gi() {
register int data = 0, w = 1;
register char ch = 0;
while (!isdigit(ch) && ch != '-') ch = getchar();
if (ch == '-') w = -1, ch = getchar();
while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar();
return w * data;
}
typedef long long ll;
int W, H, N;
set<ll> cx, cy;
multiset<ll> x, y;
multiset<ll> :: iterator ite;
int main() {
W = gi(), H = gi(), N = gi();
x.insert(W), y.insert(H);
cx.insert(0), cx.insert(W);
cy.insert(0), cy.insert(H);
for (int i = 1; i <= N; i++) {
char ch[5]; scanf("%s", ch);
int t = gi();
if (ch[0] == 'H') {
cy.insert(t); ite = cy.find(t); --ite;
ll l = *ite; ++ite; ++ite;
ll r = *ite;
ite = y.find(r - l);
y.erase(ite); y.insert(r - t); y.insert(t - l);
}
else {
cx.insert(t); ite = cx.find(t); --ite;
ll l = *ite; ++ite; ++ite;
ll r = *ite;
ite = x.find(r - l);
x.erase(ite); x.insert(r - t); x.insert(t - l);
}
ite = x.end(); --ite;
ll l = *ite;
ite = y.end(); --ite;
printf("%I64d\n", l * (*ite));
}
return 0;
}
【CF527C】Glass Carving的更多相关文章
- 【POJ1509】Glass Beads
[POJ1509]Glass Beads [题目描述]给定字符串S,并规定首尾相连成环,求出最小字典序. [输入]输入有多个数据,第一行只包括正整数N,表示有N组数据.每个数据包括一行,输入该字符串. ...
- 【codeforces 527C】Glass Carving
[题目链接]:http://codeforces.com/contest/527/problem/C [题意] 让你切割一个长方形; 只能横切或竖切; 让你实时输出切完之后最大的长方形的面积; [题解 ...
- 【POJ1509】Glass Beads 【后缀自动机】
题意 给出一个字符串,求它的最小表示法. 分析 这个题当然可以用最小表示法做啦!但是我是为了学后缀自动机鸭! 我们把这个字符串长度乘二,然后建SAM,然后在SAM上每次跑最小的那个字母,找出长度为n的 ...
- 【转】java正则表达式
在Sun的Java JDK 1.40版本中,Java自带了支持正则表达式的包,本文就抛砖引玉地介绍了如何使用java.util.regex包. 可粗略估计一下,除了偶尔用Linux的外,其他Linu ...
- AspxGridView整理文档【转】
ASPxGridView属性:概述设置(Settings) <Settings GridLines="Vertical" : 网格样式 Vertical, Both, Non ...
- Python高手之路【六】python基础之字符串格式化
Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...
- 【原】谈谈对Objective-C中代理模式的误解
[原]谈谈对Objective-C中代理模式的误解 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 这篇文章主要是对代理模式和委托模式进行了对比,个人认为Objective ...
- 【原】FMDB源码阅读(三)
[原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...
- 【原】Android热更新开源项目Tinker源码解析系列之一:Dex热更新
[原]Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Tinker是微信的第一个开源项目,主要用于安卓应用bug的热修复和功能的迭代. Tinker github地址:http ...
随机推荐
- [USACO09MAR]Sand Castle
嘟嘟嘟 太水了,大佬们就绕道吧…… 就是m, b数组分别排个序,然后更改对应位置的m[i]和b[i],就行了. 因为如果m[i]不改为b[i]而是b[i + 1]的话,那么必定要将m[j] (j &g ...
- Owin+ASP.NET Identity浅析系列(一)用户登录注册
在今天,读书有时是件“麻烦”事.它需要你付出时间,付出精力,还要付出一份心境.--仅以<Owin+ASP.NET Identity浅析系列>来祭奠那逝去的…… 使用VS2015创建MVC项 ...
- priority_queue详解
priority_queue是一个安排好的顺序存储的队列,队首是优先级最高的元素. Template<class T , class Container = vector<T> , ...
- 如何在localStorage中存取数组
默认localStorage只能存取字符串 那么如何存取数组呢 let newlist = [] localStorage.setItem('recent', JSON.stringify(newli ...
- rman基础知识理解(一)
rman用于对数据库的备份和恢复. 他的命令主要分成两大类:独立命令和批处理命令: 独立命令只能在rman的提示符下执行,主要的命令有: CONNECT CONFIGURE CREATE CATALO ...
- javascript设计模式系列二-封装
JavaScript封装: var Book = function (id, name, price) { this.id = id, this.name = name, this.price = p ...
- P1379 八数码难题
#include<iostream> #include<bits/stdc++.h> using namespace std; #include<vector> u ...
- 替代alert的消息框和提示框
alert提示框由于外观不太友好,所以一般都不用alert了. 我在这里使用bootstrap的样式,写了一个可以单独显示消息,也可以确认取消的提示框,确认,取消的采用模式对话框方式,用一个div遮盖 ...
- php 后端刷新页面
public function index() { $b = date('Y-m-d H:i:s'); header('refresh:10'); $c = strtotime($b); $d = s ...
- Spring 约束文件配置
1.引入jar包 2.新建applicationContext.xml配置文件 位置随意,建议放在src目录下 新建的空xml文件,写入一对beans标签 3.打开Windows-->Prefe ...