poj 2029 二维树状数组
思路:简单树状数组
#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 二维树状数组的更多相关文章
- POJ 1195 二维树状数组
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 18489 Accepted: 8558 De ...
- poj 3378 二维树状数组
思路:直接用long long 保存会WA.用下高精度加法就行了. #include<map> #include<set> #include<cmath> #inc ...
- poj 2155 (二维树状数组 区间修改 求某点值)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 33682 Accepted: 12194 Descript ...
- Mobile phones POJ - 1195 二维树状数组求和
Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...
- POJ 2029 Get Many Persimmon Trees (二维树状数组)
Get Many Persimmon Trees Time Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I ...
- POJ 2029 Get Many Persimmon Trees(DP||二维树状数组)
题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio ...
- POJ 2029 Get Many Persimmon Trees (模板题)【二维树状数组】
<题目链接> 题目大意: 给你一个H*W的矩阵,再告诉你有n个坐标有点,问你一个w*h的小矩阵最多能够包括多少个点. 解题分析:二维树状数组模板题. #include <cstdio ...
- POJ 2029 (二维树状数组)题解
思路: 大力出奇迹,先用二维树状数组存,然后暴力枚举 算某个矩形区域的值的示意图如下,代码在下面慢慢找... 代码: #include<cstdio> #include<map> ...
- poj 1195:Mobile phones(二维树状数组,矩阵求和)
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14489 Accepted: 6735 De ...
随机推荐
- 那些年困扰我们的委托(C#)
委托这个东西不是很好理解,可是工作中又经常用到,你随处可以看到它的身影,真让人有一种又爱又恨的感觉,我相信许多人被它所困扰过. 一提到委托,如果你学过C语言,你一定会马上联想到函数指针. 什么是委托? ...
- Unity3d:播放物理目录下的MP3文件
u3d里,是支持播放MP3文件的,但要放到资源里,不支持播放物理目录下的MP3文件.由于界面上无需显示,只是当作背景音乐来播放,所以想到调用c#的组件来解决此问题.主要代码都在附件中,根据需要加到自己 ...
- Use jQuery to hide a DIV when the user clicks outside of it
http://stackoverflow.com/questions/1403615/use-jquery-to-hide-a-div-when-the-user-clicks-outside-of- ...
- Java浮点数精确计算
BigDecimal是Java提供的一个不变的.任意精度的有符号十进制数对象.
- requests设置headers,proxies,cookies
header = {'referer':'http://www.baidu.com'} # referer代表从什么网页跳过来的,其他属性同理设置 proxy = { 'http':'115.28.5 ...
- listView divider marginLeft marginRight
要实现这样的效果: 新建drawable 用inset 进行实现.代码如下: <?xml version="1.0" encoding="utf-8"? ...
- 实用的树形菜单控件tree
jQuery plugin: Treeview 这个插件能够把无序列表转换成可展开与收缩的Tree. jQuery plugin: Treeview jQuery jstree jsTree ...
- List排序忽略大小写
public List<String> sortListIgnoreCase(List<String> list) { Collections.sort(list ...
- MySQL 索引优化 btree hash rtree
一.MySQL索引类型 mysql里目前只支持4种索引分别是:full-text,b-tree,hash,r-tree b-tree索引应该是mysql里最广泛的索引的了,除了archive基本所有的 ...
- Educational Codeforces Round 4 B. HDD is Outdated Technology 暴力
B. HDD is Outdated Technology 题目连接: http://www.codeforces.com/contest/612/problem/B Description HDD ...