codeforces 527C:STL set
2016-01-17 18:59
387 查看
x和y各用一个set保存切割点
L[k] H[k]记录长度为k的线段有几个
每添加一个切点,更新L[] H[],然后找到各找到最大值,相乘就是答案
关键是学学set的使用
L[k] H[k]记录长度为k的线段有几个
每添加一个切点,更新L[] H[],然后找到各找到最大值,相乘就是答案
关键是学学set的使用
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 #include"cstdio" #include"queue" #include"cmath" #include"stack" #include"iostream" #include"algorithm" #include"cstring" #include"queue" #include"map" #include"set" #include"vector" #define ll long long #define mems(a,b) memset(a,b,sizeof(a)) #define ls pos<<1 #define rs pos<<1|1 using namespace std; const int MAXN = 200500; const int MAXE = 200500; const int INF = 0x3f3f3f3f; set<int> h,v; int L[MAXN],H[MAXN]; int main(){ int x,y,n,ch=0,cv=0; scanf("%d%d%d",&y,&x,&n); mems(L,0); mems(H,0); h.insert(0);v.insert(0); h.insert(x);v.insert(y); int mxx=x,mxy=y; L[x]=H[y]=1; for(int i=0;i<n;i++){ char arr[5]; int t; set<int>::iterator l,r,mid; scanf("%s %d",arr,&t); if(arr[0]=='H'){ h.insert(t); l=r=mid=h.find(t); l--;r++; L[*r-*l]--; L[*r-*mid]++; L[*mid-*l]++; if(!L[mxx]) while(!L[mxx]) mxx--; } else{ v.insert(t); l=r=mid=v.find(t); l--;r++; H[*r-*l]--; H[*r-*mid]++; H[*mid-*l]++; if(!H[mxy]) while(!H[mxy]) mxy--; } //cout<<mxx<<'\t'<<mxy<<endl; printf("%I64d\n",(ll)mxx*mxy); } return 0; }
相关文章推荐
- CentOS隐藏nginx版本号
- 环信
- ios让你简单实现瀑布流
- 使用FFMPEG从MP4封装中提取视频流到H264文件
- 清空file input框
- (一)1月14日直播视频
- 新PaaS平台上线数据初始化经验
- SGU 532. Building Foundation 暴力
- poi操作
- get方法和set 方法的命名规则
- codeforces 527B:瞎搞
- Android Lolipop AssetAtlasService引起的系统崩溃
- 时钟中断(2)
- Windows下安装TexLive遇到的问题
- 关于获取Java的调用栈的实现
- 学习笔记 --- 最小费用最大流
- android layout_gravity失效的问题
- C/C++中常出现的#ifndef,#define,#endif解析
- 学习笔记 --- 最小费用最大流
- eclipse 插件安装问题