思路:简单树状数组

#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. 小知识~让你的DLL类库带上注释

    在我们进行开发公用组件时,一般会把DLL给团队的开发人员直接使用,而不会把项目给他们,因为那样对为框架级代码是不安全的,这时引用框架类库有两种方式,一种是直接复制DLL,第一种是使用包管理工具Nuge ...

  2. .NET常用类库--苏飞合集

    在线网站:http://tool.sufeinet.com/CodePreview/CodeView.aspx?action=view&file=Zip/SharpZip.cs C#基类库大全 ...

  3. myeclipse、eclipse中项目复制后(可能无法访问)注意事项 .

    .myEclipse 复制后修改名称,访问不到项目 这是因为,你只是改了项目的名称,而没有改 下面是解决方法: 方法 1.右击你的项目,选择“properties”,在“type filter tex ...

  4. Cocos2dx Widget button透明区域过滤

    小伟哥 遇到一个命题: button透明区域过滤.当点击一个建筑button.花的时候不得不想一些方法把点击透明区域过滤掉. 让点击也没有效果滴啦. 開始搜索了半天才有所思路. 在网络上非常多贴代码的 ...

  5. [原创]jQuery的this和$(this)

    网上有很多关于jQuery的this和$(this)的介绍,大多数只是理清了this和$(this)的指向,其实它是有应用场所的,不能一概而论在jQuery调用成员函数时,this就是指向dom对象. ...

  6. git有merge时如何删除分支

    不小心增加了一个分支,并且有了merge,如何删除掉? 具有merge时不能切换分支 可以利用git stash命令 git rm controllers/InterfaceController.ph ...

  7. Codeforces Round #310 (Div. 1) C. Case of Chocolate set

    C. Case of Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/ ...

  8. TXT EXPLORER

    EXE程序:http://files.cnblogs.com/xe2011/RELEASE_TXTExplorer2014-08-25-165323.rar c# 源码:http://files.cn ...

  9. progressBarButton

    https://github.com/longtaoge/progressBarButton

  10. Android 多级树形菜单

    在Android里要实现树形菜单,都是用ExpandableList(也有高手自己继承ListView或者LinearLayout来做),但是ExpandableList一般只能实现2级树形菜单... ...