题意:n*m的方格,“0 x”表示x轴在x位置切一刀,“0 y”表示y轴在y位置切一刀,每次操作后输出当前面积最大矩形。

思路:用set分别储存x轴y轴分割的点,用multiset(可重复)储存x轴y轴边,每次输出最大的长和最大的宽的积。题目可能重复切。multiset如果直接erase(13)会把所有的13都删掉,如果只想删一个则erase(multiset.find(13))。第一次知道set自带二分...

这里multiset也可以用map<int, int, greater<int> >,然后用迭代器指向最后一个key就行了

代码:

#include<set>
#include<map>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn = + ;
const int seed = ;
const int MOD = + ;
const int INF = 0x3f3f3f3f;
set<ll> x, y;
multiset<ll> lenx, leny;
int main(){
int T;
ll n, m, q;
scanf("%d", &T);
while(T--){
scanf("%lld%lld%lld", &n, &m, &q);
x.clear();
y.clear();
lenx.clear();
leny.clear();
x.insert(),x.insert(n),lenx.insert(n);
y.insert(),y.insert(m),leny.insert(m);
set<ll>::iterator it;
while(q--){
ll o, p;
scanf("%lld%lld", &o, &p);
if(o == && x.count(p) == ){
it = x.lower_bound(p);
lenx.insert(*it - p);
int len = *it - *(--it);
lenx.erase(lenx.find(len));
lenx.insert(p - *it);
x.insert(p);
}
else if(o == && y.count(p) == ){
it = y.lower_bound(p);
leny.insert(*it - p);
int len = *it - *(--it);
leny.erase(leny.find(len));
leny.insert(p - *it);
y.insert(p);
}
it = lenx.end();
ll chang = *(--it);
it = leny.end();
ll kuan = *(--it);
printf("%lld\n", chang * kuan);
}
}
return ;
}

最新文章

  1. 总结六条对我们学习Linux系统有用的忠告
  2. [外挂4] 用CE查找棋盘基址
  3. hdu 饭卡
  4. DATEADD(Day, DATEDIFF(Day,0,ShippingTime), 0)
  5. Python 删除列表中的重复数据
  6. UVA 11082 Matrix Decompressing 矩阵解压(最大流,经典)
  7. Ext.useShims=true
  8. 深入Java虚拟机读书笔记第二章平台无关性
  9. CentOS和Ubuntu的区别
  10. HDU 4859(Bestcoder #1 1003)海岸线(网络流之最小割)
  11. ZOJ 2853 Evolution 【简单矩阵快速幂】
  12. 于ubuntu-kylin14.10下一个,无法使用apt-get具( libc6-i386 : 赖: libc6 (= 2.15-0ubuntu10.5) 但 2.19-0ubuntu6 一个已)
  13. 初步swift该研究指出语言(基本数据类型)
  14. Python文件夹备份
  15. 使用JavaMail发送带附件的邮件
  16. hdu2669与hdu1576(扩展欧几里德)
  17. 【R】资源整理
  18. Vue 中 diff 算法后更新 DOM 的方法
  19. C# 特性学习笔记
  20. apache-tomcat-7.0.53-windows-x86或者x64:出现错误提示:(Unable to open the service &#39;tomcat7)或者(Failed installing &#39;Tomcat7&#39; service) tomcat7 %1 不是有效的 Win32 应用程序。

热门文章

  1. 滑雪---poj1088(动态规划+记忆化搜索)
  2. GOLANG错误处理最佳方案errors wrap, Defer, Panic, and Recover
  3. (转)Elasticsearch查询规则------match和term
  4. HDU5012:Dice(bfs模板)
  5. pandas使用drop_duplicates去除DataFrame重复项
  6. CNN实现垃圾邮件分类(行大小不一致要补全)
  7. (转)mysql数据文件解析
  8. iOS 设计模式-委托模式
  9. 全文搜索引擎Xapian
  10. linux常用命令:telnet 命令