poj 2029 Get Many Persimmon Trees (dp)
又是一道完全自己想出来的dp题。
题意:一个w*h的图中,有n个点,给一个s*t的圈,求这个圈能 圈的最多的点
分析:d[i][j]代表i行j列 到第一行第一列的这个方框内有多少个点, 然后枚举圈的右下角的点,
计算在圈的范围的点的方法为
d[i][j]-d[i][j-s]-d[i-t][j]+d[i-t][j-s]。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
const int maxn = + ;
int d[][], G[][];
int n, w, h, s, t; int main()
{
int i, j, x, y, sum, ans;
while(~scanf("%d", &n) && n)
{
ans = ;
memset(d, , sizeof(d));
memset(G, , sizeof(G));
scanf("%d%d", &w, &h);
for(i = ; i <= n; i++)
{
scanf("%d%d", &x, &y);
G[y][x] = ;
}
scanf("%d%d", &s, &t);
for(i = ; i <= h; i++)
{
sum = ;
for(j = ; j <= w; j++)
{
if(G[i][j] == )
sum++;
d[i][j] = d[i-][j] + sum;
}
}
for(i = t; i <= h; i++)
for(j = s; j <= w; j++)
{
ans = max(ans, d[i][j]-d[i][j-s]-d[i-t][j]+d[i-t][j-s]);
}
printf("%d\n", ans);
}
return ;
}
poj 2029 Get Many Persimmon Trees (dp)的更多相关文章
- (简单) 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 Get Many Persimmon Trees 各种解法都有,其实就是瞎搞不算吧是dp
连接:http://poj.org/problem?id=2029 题意:给你一个map,然后在上面种树,问你h*w的矩形上最多有几棵树~这题直接搜就可以.不能算是DP 用树状数组也可作. #incl ...
- POJ 2029 Get Many Persimmon Trees(DP||二维树状数组)
题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio ...
- POJ 2029 Get Many Persimmon Trees(水题)
题意:在w*h(最大100*100)的棋盘上,有的格子中放有一棵树,有的没有.问s*t的小矩形,最多能含有多少棵树. 解法:最直接的想法,设d[x1][y1][x2][y2]表示选择以(x1, y1) ...
- POJ 2029 Get Many Persimmon Trees (模板题)【二维树状数组】
<题目链接> 题目大意: 给你一个H*W的矩阵,再告诉你有n个坐标有点,问你一个w*h的小矩阵最多能够包括多少个点. 解题分析:二维树状数组模板题. #include <cstdio ...
- POJ 2029 Get Many Persimmon Trees 【 二维树状数组 】
题意:给出一个h*w的矩形,再给出n个坐标,在这n个坐标种树,再给出一个s*t大小的矩形,问在这个s*t的矩形里面最多能够得到多少棵树 二维的树状数组,求最多能够得到的树的时候,因为h,w都不超过50 ...
- poj2029 Get Many Persimmon Trees
http://poj.org/problem?id=2029 单点修改 矩阵查询 二维线段树 #include<cstdio> #include<cstring> #inclu ...
随机推荐
- 2435: [Noi2011]道路修建 - BZOJ
Description 在 W 星球上有 n 个国家.为了各自国家的经济发展,他们决定在各个国家之间建设双向道路使得国家之间连通.但是每个国家的国王都很吝啬,他们只愿意修建恰好 n – 1条双向道路. ...
- mysql 的日志文件
mysql的日志文件 日志文件大致分为 error log, binary log, query log, slow query log, innodb redo log ;如图: 1.error ...
- 【tarjan】BZOJ 1051:受欢迎的牛
1051: [HAOI2006]受欢迎的牛 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3134 Solved: 1642[Submit][Sta ...
- 【HDOJ】【2089】不要62
数位DP cxlove基础数位DP第一题 用容斥把所有的不吉利数字去掉就得到吉利数字的数量= =(满足区间减法) //HDOJ 2089 #include<cmath> #include& ...
- WinForm员工信息表
先搞一个panel,然后里面放label.
- css文件都写在一个里面还是每个页面都引用单独的css样式好?
因为网站比较小,外加网站页面有很多重复构件,决定采用“构件复用”搭建网页,但是遇到了一个问题.因为虽然有共同的css,但是每个页面或多或少都有独立的样式控制,到底是写在同一个css还是分离看上去清楚一 ...
- 基于 Eclipse 平台的代码生成技术
------------------------------------------------------------------ 转自http://www.ibm.com/developerwor ...
- mac下SVN上传.a静态库文件
在mac下很多svn管理工具默认都不能上传.a文件,但是用命令行可以解决此问题. 打开终端,cd 进入到需要上传的.a文件所在的文件夹. 确保 ls能看到.a文件 然后使用命令,如:svn add l ...
- Unity3D 集合插件目录
http://unity3d.9ria.com/?p=2171 这个基本上很全 下面自己觉的还不错的,当然那些大众的就不列出来了 一.KGFMapSystem Quick Start : http:/ ...
- 【unity3d游戏开发之基础篇】unity3d射线的原理用法以及一个利用射线实现简单拾取的小例子
原地址:http://www.cnblogs.com/xuling/archive/2013/03/04/2943154.html 最近开始研究U3D,它的强大就不多说了, 今天研究了研究射线相关东西 ...