思路:简单树状数组

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pb push_back
#define mp make_pair
#define Maxn 120
#define Maxm 80002
#define LL __int64
#define Abs(x) ((x)>0?(x):(-x))
#define lson(x) (x<<1)
#define rson(x) (x<<1|1)
#define inf 0x7fffffff
#define lowbit(x) (x&(-x))
#define Mod 1000000007
using namespace std;
int c[Maxn][Maxn],w,h,n;
void update(int x,int y)
{
int yy=y;
while(x<=w){
y=yy;
while(y<=h){
c[x][y]++;
y+=lowbit(y);
}
x+=lowbit(x);
}
}
int sum(int x,int y)
{
int sum=,yy=y;
while(x){
y=yy;
while(y){
sum+=c[x][y];
y-=lowbit(y);
}
x-=lowbit(x);
}
return sum;
}
int main()
{
int n,i,j,x,y;
while(scanf("%d",&n)!=EOF,n){
memset(c,,sizeof(c));
scanf("%d%d",&w,&h);
for(i=;i<=n;i++){
scanf("%d%d",&x,&y);
update(x,y);
}
scanf("%d%d",&x,&y);
int ans=;
for(i=x;i<=w;i++){
for(j=y;j<=h;j++){
ans=max(ans,sum(i,j)-sum(i-x,j)-sum(i,j-y)+sum(i-x,j-y));
}
}
printf("%d\n",ans);
}
return ;
}

poj 2029 二维树状数组的更多相关文章

  1. POJ 1195 二维树状数组

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 18489   Accepted: 8558 De ...

  2. poj 3378 二维树状数组

    思路:直接用long long 保存会WA.用下高精度加法就行了. #include<map> #include<set> #include<cmath> #inc ...

  3. poj 2155 (二维树状数组 区间修改 求某点值)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 33682   Accepted: 12194 Descript ...

  4. Mobile phones POJ - 1195 二维树状数组求和

    Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...

  5. POJ 2029 Get Many Persimmon Trees (二维树状数组)

    Get Many Persimmon Trees Time Limit:1000MS    Memory Limit:30000KB    64bit IO Format:%I64d & %I ...

  6. POJ 2029 Get Many Persimmon Trees(DP||二维树状数组)

    题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio ...

  7. POJ 2029 Get Many Persimmon Trees (模板题)【二维树状数组】

    <题目链接> 题目大意: 给你一个H*W的矩阵,再告诉你有n个坐标有点,问你一个w*h的小矩阵最多能够包括多少个点. 解题分析:二维树状数组模板题. #include <cstdio ...

  8. POJ 2029 (二维树状数组)题解

    思路: 大力出奇迹,先用二维树状数组存,然后暴力枚举 算某个矩形区域的值的示意图如下,代码在下面慢慢找... 代码: #include<cstdio> #include<map> ...

  9. poj 1195:Mobile phones(二维树状数组,矩阵求和)

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14489   Accepted: 6735 De ...

随机推荐

  1. redis的发布订阅模式

    概要 redis的每个server实例都维护着一个保存服务器状态的redisServer结构 struct redisServer {     /* Pubsub */     // 字典,键为频道, ...

  2. VC++ 6.0中实现三叉切分窗口与多视图 [转]

    一.引用 当用户需要同时对文当的不同部分进行编辑时,常常会用到切分窗口;这些窗口可以都是相同的视,或者一个窗口为列表视,而另一个为树型视图.应用程序框架有多种方式来表示多视图,切分窗口是其中的方式之一 ...

  3. extjs表格下的分页条——Ext.grid.Panel 的 pagingtoolbar

    两种分页条:每页固定条数的分页条 和 自定义选择每页内容条数的分页条 一.每页固定条数的分页条 这种样式的-- dockedItems: [{ xtype: 'pagingtoolbar', stor ...

  4. Slony-I的删除:

    接前篇:http://www.cnblogs.com/gaojian/p/3196244.html 简单的Slony-I设置实例 如何删除slony相关的内容呢. 我再另外找一台机器,安装slony, ...

  5. OAB配置

    OAB管理: http://blogs.technet.com/b/exchange_chs/archive/2013/01/31/exchange-server-2013-oab-managing- ...

  6. Codeforces 427 D. Match &amp; Catch

    后缀数组.... 在两个串中唯一出现的最小公共子串 D. Match & Catch time limit per test 1 second memory limit per test 51 ...

  7. PHP 获取js中变量的方法

    留作笔记 <php? $aaa="<script>document.write(1)</script>"; echo $aaa; ?> 其中数字 ...

  8. 【M30】代理类

    1.考虑二维数组,在栈上分配,必须在编译时确定大小,也就是大小是常量.另外一点,C++不支持在堆上分配二维数组.怎么解决这个问题? 二维数组可以看成,一维数组的数组.因此,可以使用代理类,Array2 ...

  9. Codeforces Round #340 (Div. 2) C. Watering Flowers 暴力

    C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerb ...

  10. Codeforces Round #338 (Div. 2) E. Hexagons 讨论讨论

    E. Hexagons 题目连接: http://codeforces.com/contest/615/problem/E Description Ayrat is looking for the p ...