poj 2029
来源:互联网 发布:电子屏图文信息软件 编辑:程序博客网 时间:2024/06/05 05:05
题目:http://poj.org/problem?id=2029
二维树状数组,0(n^2)枚举矩形右下角的坐标即可。
#include <cmath>#include <ctime>#include <iostream>#include <string>#include <vector>#include <cstdio>#include <cstdlib>#include <cstring>#include <queue>#include <map>#include <set>#include <algorithm>#include <cctype>#include <stack>#include <deque>using namespace std;typedef long long LL;#define EPS 10e-9#define INF 0x3f3f3f3f#define REP(i,n) for(int i=0; i<(n); i++)const int maxn = 110;int c[maxn][maxn];int lowbit(int x){ return x&-x;}void add(int x,int y){ while(x<maxn){ int y1=y; while(y1<maxn){ c[x][y1]+=1; y1+=lowbit(y1); } x+=lowbit(x); }}int sum(int x,int y){ int ret=0; while(x>0){ int y1=y; while(y1>0){ ret+=c[x][y1]; y1-=lowbit(y1); } x-=lowbit(x); } return ret;}int main(){ int n,w,h,s,t,ans,x,y; while(scanf("%d",&n)!=EOF){ if(n==0) break; ans=0; memset(c,0,sizeof(c)); scanf("%d%d",&w,&h); for(int i=0;i<n;i++){ scanf("%d %d",&x,&y); add(x,y); } scanf("%d %d",&s,&t); for(int i=s;i<=w;i++){ for(int j=t;j<=h;j++){ int temp=sum(i,j); int x1=i-s; int y1=j-t; if(x1>=0){ temp-=sum(x1,j); } if(y1>=0){ temp-=sum(i,y1); } if(x1>=0&&y1>=0){ temp+=sum(x1,y1); } if(temp>ans) { ans=temp; // printf("this %d %d %d\n",ans,i,j); } } } printf("%d\n",ans); } return 0;}
- POJ 2029
- poj 2029
- poj 2029
- poj-2029
- POJ 2029
- POJ 2029 预处理
- POJ 2029 DP || 暴力
- POJ 2029 水DP
- POJ 2029 递推
- poj 2029 树状数组
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- 设计模式-FlyWeight
- SetROP2函数 ——设置前景色与背景色
- linux中Oops信息的调试及栈回溯—Linux人都知道,这是好东西!
- WEB原型设计工具Mockup
- 多玩YY靠屌丝用户突出腾讯重围成功上市
- poj 2029
- 真正优秀的程序员有哪些与众不同之处?
- 使用 windbg 分析 minidump
- jquery始终显示DIV中央
- 整型提升
- Linux vim编辑器打开文件警告E325: ATTENTION解决
- java经典算法_003水仙花数
- scanf
- 中科院报告:360产品存在三大隐私安全问题