poj 2029 Get Many Persimmon Trees 各种解法都有,其实就是瞎搞不算吧是dp
连接:http://poj.org/problem?id=2029
题意:给你一个map,然后在上面种树,问你h*w的矩形上最多有几棵树~这题直接搜就可以。不能算是DP
用树状数组也可作。
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#define loop(s,i,n) for(i = s;i < n;i++)
#define cl(a,b) memset(a,b,sizeof(a))
using namespace std;
const int MAX = ;
int map[MAX][MAX];
int dp[MAX][MAX]; int main(){
int n, i, j, ii, jj;
int W, H, w, h;
while(cin >> n && n){
memset(map, , sizeof(map));
memset(dp, , sizeof(dp));
cin >> W >> H;
while(n --){
int x, y;
cin >> x >> y;
map[y][x] = ;
}
cin >> w >> h;
for(i = ; i <= H; i ++)
for(j = ; j <= W; j ++)
dp[i][j] = dp[i-][j] + dp[i][j-] - dp[i-][j-] + map[i][j];
int ans = ;
for(i = ; i <= H; i ++)
for(j = ; j <= W; j ++){
ii = i - h + ;
jj = j - w + ;
if(ii < || jj < ) continue;
ans = max(ans, dp[i][j] - dp[ii-][j] - dp[i][jj-] + dp[ii-][jj-]);
}
cout << ans << endl;
}
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(水题)
题意:在w*h(最大100*100)的棋盘上,有的格子中放有一棵树,有的没有.问s*t的小矩形,最多能含有多少棵树. 解法:最直接的想法,设d[x1][y1][x2][y2]表示选择以(x1, y1) ...
- 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 (模板题)【二维树状数组】
<题目链接> 题目大意: 给你一个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 ...
随机推荐
- jQuery.outerWidth() 函数具体解释
outerWidth()函数用于设置或返回当前匹配元素的外宽度.外宽度默认包含元素的内边距(padding).边框(border),但不包含外边距(margin)部分的宽度.你也能够指定參数为true ...
- [css]单/多行居中&字体设置
行高和字号 行高 CSS中,所有的行,都有行高.盒模型的padding,绝对不是直接作用在文字上的,而是作用在"行"上的. line-height: 40px; 文字,是在自己的行 ...
- python3 捕捉代码行出错的小程序
下面主要使用的是: try .. except .. else .. finally ...,用的是 traceback 这个第三方模块. import traceback #捕捉哪行代码报错 def ...
- ReactNative生成android平台的bundle文件命令
ReactNative生成android平台的bundle文件命令 2016年11月03日 23:23:28 阅读数:4869 注:如果assets文件没有正确生成,需要手机创建或授权 网上的其它的很 ...
- 关于Oracle误操作--数据被Commit后的数据回退恢复(闪回)
今天操作Oracle数据库时,做一个Update数据时,不小心少写了个where,看这粗心大意的. 于是乎,把所有的员工工号都给更新成一个同一个工号了.这是一个悲催的故事. 因为工号是Check了好多 ...
- Keras实践:模型可视化
Keras实践:模型可视化 安装Graphviz 官方网址为:http://www.graphviz.org/.我使用的是mac系统,所以我分享一下我使用时遇到的坑. Mac安装时在终端中执行: br ...
- 时间格式—My97DatePicker控件使用
一.My97DatePicker控件使用(2步): 1:JSP页面:( class="Wdate" 显示控件图标) 引入控件包中的脚本: <script type=&qu ...
- 77. Combinations(回溯)
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: I ...
- js 中的[] {}是什么意思
<div id="aa1">aaaaa</div><div id="aa2">bbbb</div><div ...
- redis入门学习记录(一)
1.linux在线下载Redis ,官网地址:https://redis.io/download目前,最新的Redist版本为redis-5.0.0,使用wget下载 进入/usr/local/src ...