hdu 2462
来源:互联网 发布:java log4j的使用 编辑:程序博客网 时间:2024/06/11 22:14
OJ
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <vector>#include <map>#include <set>#include <string>#include <cstring>#include <list>#include <queue>#include <stack>#include <cmath>using namespace std;#define PF(x) (scanf("%d",&x))#define PT(x,y) (scanf("%d%d",&x,&y))#define PR(x) (printf("%d\n",x))#define PRT(x,y)(printf("%d %d\n",x,y))#define M 1005int arr[M][M];int maxx(int x,int y){return x>y?x:y;}int minx(int x,int y){return x>y?y:x;}int low(int x){return x&(-x);}void add(int x,int y,int c){int t=y;for(x;x<M;x+=low(x))for(t = y;t<M;t+=low(t))arr[x][t]+=c;}int sums(int x,int y){int sumt = 0;int t;for(;x;x-=low(x))for(t=y;t;t-=low(t))sumt += arr[x][t];return sumt;}int getsum(int x,int y,int xx,int yy){return sums(xx,yy)+sums(x-1,y-1)-sums(x-1,yy)-sums(xx,y-1);}void init(){int q;while(scanf("%d",&q)!=EOF){memset(arr,0,sizeof(arr));char ch[10];int x,y,xx,yy;for(int i=0;i<q;i++){scanf("%s",ch);if(ch[0]=='B'){PT(x,y);x++,y++;int a = getsum(x,y,x,y);if(a==0) add(x,y,1);}else if(ch[0] == 'D'){PT(x,y);x++,y++;int a = getsum(x,y,x,y);if(a==1) add(x,y,-1);}else{PT(x,xx);PT(y,yy);x++,xx++,y++,yy++;int ix = minx(x,xx);int iy =minx(y,yy);int ax = maxx(x,xx);int ay = maxx(y,yy);PR(getsum(ix,iy,ax,ay));}}}return ;}int main(){init();return 0;}
- hdu 2462
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- 想请一位在校学生开发程序,有时间和精力的举手哦
- Winform中listView控件从数据库中添加数据的方法
- iphone 开发环境大家
- 项目管理知识体系系指南学习总结(一)
- 2012-07-16
- hdu 2462
- 英语词汇6
- Snmp网络管理协议
- 八章 札记--C++ primer 之旅
- 插入关联表数据的优化方法
- Android 4.1 Jelly Bean(果冻豆) 源码下载
- 编码工艺Coding Techniques)-命名和注释
- AMD处理器&VM8.0 完美安装Mac OS X 10.6.0 并成功升级至10.6.8 成功安装 Xcode 4.2
- Photoshop 图层合并机制之正片叠底