POJ 2029
二维树状数组可解此题
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define lowbit(x) (x)&(-x) using namespace std;
int sum[105][105],k,n,m;
int W,H; void gp(int x,int y){
int t;
for(;x<=n;x+=lowbit(x))
for(t=y;t<=m;t+=lowbit(t))
sum[x][t]+=1;
} int gs(int x,int y){
int s=0,t;
for(;x;x-=lowbit(x))
for(t=y;t;t-=lowbit(t))
s+=sum[x][t];
return s;
} int gst(int x1,int y1,int x2,int y2){
return gs(x2,y2)-gs(x1-1,y2)-gs(x2,y1-1)+gs(x1-1,y1-1);
} int main(){
int s,h; int maxt;
while(scanf("%d",&k),k){
maxt=-1;
memset(sum,0,sizeof(sum));
scanf("%d%d",&n,&m);
for(int i=1;i<=k;i++){
scanf("%d%d",&s,&h);
gp(s,h);
}
scanf("%d%d",&W,&H);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
maxt=max(maxt,gst(i-W<=0?1:(i-W+1),j-H<=0?1:(j-H+1),i,j));
}
}
printf("%d\n",maxt);
}
return 0;
}
POJ 2029的更多相关文章
- poj 2029 Get Many Persimmon Trees 各种解法都有,其实就是瞎搞不算吧是dp
连接:http://poj.org/problem?id=2029 题意:给你一个map,然后在上面种树,问你h*w的矩形上最多有几棵树~这题直接搜就可以.不能算是DP 用树状数组也可作. #incl ...
- (简单) POJ 2029 Get Many Persimmon Trees,暴力。
Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aiz ...
- 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
Get Many Persimmon Trees Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3243 Accepted: 2 ...
- poj 2029 二维树状数组
思路:简单树状数组 #include<map> #include<set> #include<cmath> #include<queue> #inclu ...
- POJ 2029 Get Many Persimmon Trees(DP||二维树状数组)
题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio ...
- poj 2029 Get Many Persimmon Trees (dp)
题目链接 又是一道完全自己想出来的dp题. 题意:一个w*h的图中,有n个点,给一个s*t的圈,求这个圈能 圈的最多的点 分析:d[i][j]代表i行j列 到第一行第一列的这个方框内有多少个点, 然后 ...
- POJ 2029 Get Many Persimmon Trees(水题)
题意:在w*h(最大100*100)的棋盘上,有的格子中放有一棵树,有的没有.问s*t的小矩形,最多能含有多少棵树. 解法:最直接的想法,设d[x1][y1][x2][y2]表示选择以(x1, y1) ...
- POJ 2029 DP || 暴力
在大矩形中找一个小矩形 使小矩形包括的*最多 暴力或者DP 水题 暴力: #include "stdio.h" #include "string.h" int ...
- POJ 2029 Get Many Persimmon Trees (模板题)【二维树状数组】
<题目链接> 题目大意: 给你一个H*W的矩阵,再告诉你有n个坐标有点,问你一个w*h的小矩阵最多能够包括多少个点. 解题分析:二维树状数组模板题. #include <cstdio ...
随机推荐
- 93.EXTJS Form之VTypes
转自:http://blog.sina.com.cn/s/blog_7778950d0100y2pg.html 本文我们主要探讨一下EXTJS的Form中验证的问题,可能用过EXTJS的Form的人都 ...
- php循环跳出
PHP中的循环结构大致有for循环,while循环,do{} while 循环以及foreach循环几种,不管哪种循环中,在PHP中跳出循环大致有这么几种方式: 代码: <?php $i = 1 ...
- 没调出来 P2023
#include<iostream> #include<cstdio> #include<cstring> #define ll long long #define ...
- spark作业运行过程之--DAGScheduler
DAGScheduler--stage划分和创建以及stage的提交 本篇,我会从一次spark作业的运行为切入点,将spark运行过程中涉及到的各个步骤,包括DAG图的划分,任务集的创建,资源分配, ...
- F - Modular Exponentiation
Problem description The following problem is well-known: given integers n and m, calculate 2n mod m, ...
- 导入不同业务数据通过Excel实现
很多公司都用到了老系统移植到新系统,数据自然也需要迁移,这个解决方案之一就是使用Excel文件导入. 结合公司实现,然后简单写了个Demo. (PS:去找朋友本想着花几十分钟弄出来炫耀一波,结果花了三 ...
- Spring Boot (17) 发送邮件
添加依赖 <!--发送邮件 --> <dependency> <groupId>org.springframework.boot</groupId> & ...
- angular js shopping
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- js-内置对象及相关语法
1:如图(视频截取的) this指的是当前标签的对象. var ary=new Array("mark","jay","leslie"); ...
- Dijkstra的双栈算术表达式求值算法 C++实现
#include<iostream> #include<string> using namespace std; template<typename T> clas ...