题意:给出一个h*w的矩形,再给出n个坐标,在这n个坐标种树,再给出一个s*t大小的矩形,问在这个s*t的矩形里面最多能够得到多少棵树

二维的树状数组,求最多能够得到的树的时候,因为h,w都不超过500,直接暴力

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std; typedef long long LL;
const int INF = (<<)-;
const int mod=;
const int maxn=; int c[maxn][maxn]; int lowbit(int x){ return x & (-x);} int sum(int x,int y){
int ret=;
int y1;
while(x > ){
y1=y;
while(y1 > ){
ret += c[x][y1];y1-=lowbit(y1);
}
x-=lowbit(x);
}
return ret;
} void add(int x,int y,int d){
int y1;
while(x < maxn){
y1=y;
while(y1 < maxn){
c[x][y1] += d;y1+=lowbit(y1);
}
x+=lowbit(x);
}
} int main(){
int n;
while(scanf("%d",&n)!=EOF && n){
memset(c,,sizeof(c));
int w,h;
scanf("%d %d",&w,&h);
while(n--){
int u,v;
scanf("%d %d",&u,&v);
add(v,u,);
}
int x,y;
scanf("%d %d",&x,&y);swap(x,y); int ans=-;
int tmp=;
for(int i=;i <=h;i++){
for(int j=;j<=w;j++){
tmp = sum(i+x-,j+y-)-sum(i-,j+y-)-sum(i+x-,j-)+sum(i-,j-);
ans = max(ans,tmp);
}
}
printf("%d\n",ans);
}
return ;
}

POJ 2029 Get Many Persimmon Trees 【 二维树状数组 】的更多相关文章

  1. POJ2029:Get Many Persimmon Trees(二维树状数组)

    Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aiz ...

  2. [poj2155]Matrix(二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 25004   Accepted: 9261 Descripti ...

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

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

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

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

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

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

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

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

  7. Get Many Persimmon Trees_枚举&&二维树状数组

    Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aiz ...

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

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

  9. POJ 2155 Matrix【二维树状数组+YY(区间计数)】

    题目链接:http://poj.org/problem?id=2155 Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissio ...

  10. POJ 2155 Matrix(二维树状数组,绝对具体)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 20599   Accepted: 7673 Descripti ...

随机推荐

  1. Redis运维时需要注意的参数

    1: 内存 Memory used_memory:859192 数据结构的空间 used_memory_rss:7634944 实占空间 mem_fragmentation_ratio:8.89 前2 ...

  2. Controller总结

    下图显示了组建之间的基本控制流程 1.1控制器工厂.动作调用器 控制器工厂负责创建对请求进行服务的控制器实例 动作调用其负责查找并调用控制器类中的动作方法. 1.2自定义控制器工厂 namespace ...

  3. CLR - 基础

    前言 好记性不如烂“笔头”系列... 目录 托管模块 JIT(just-in-time) 元数据 CLR 解析类型引用 托管模块 面向 CLR 的编译器在编译源文件时最终会编译成一个 PE(可移植执行 ...

  4. javascript中全屏滑动效果实现

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. zeromq-4.1.2在windows下的编译

    作者:朱金灿 来源:http://blog.csdn.net/clever101 zeromq是一个最近比较火的跨平台消息中间件,最近准备研究它,故下载它的源码编译了一下.我是使用VS2008编译的, ...

  6. Declarative programming-声明式编程-布局约束是一个案例

    声明式编程需要底层或运行时环境支持. 声明式语言的关键词确定了执行的关键控制流. 表述编程语言是说明性的东西:而不是具体的执行方案. 通常他的执行由解释器进行. In computer science ...

  7. RocketMQ学习笔记(12)----RocketMQ的Consumer API简介

    由于消息的消费方式有两种,所以两种方式也有不同的API: 1. PushConsumer的配置 1. consumerGroup: 默认值为DEFAULT_CONSUMER,Consumer组名,多个 ...

  8. ZBrush通过显示与隐藏得到子物体

    在ZBrush®中得到子物体的方法有很多,本文将为大家介绍一种新的创建子物体的方法,通过显示和隐藏得到子物. ZBrush 4R8中文版下载:http://wm.makeding.com/iclk/? ...

  9. BarTender无法连接到数据库?原来是微软补丁包捣的鬼

    近期有很多BarTender用户反映,在使用BarTender设计打印条码时,经常会出现错误消息6670 的提示,使得BarTender无法连接到数据库,究其原因,原来是微软补丁包捣的鬼.目前海鸥科技 ...

  10. 面试题sql

    查询书的价格10到20 之前显示10to20 没有显示unknown CREATE TABLE book(price INT,NAME VARCHAR(20)) SELECT NAME AS '名字' ...