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 ...
随机推荐
- Spring Boot - Building RESTful Web Services
Spring Boot Building RESTful Web Services https://www.tutorialspoint.com/spring_boot/spring_boot_bui ...
- SVN跨版本库迁移目录并保留提交日志
现在有一份代码code在版本库reposA/dirB/下,现在想把它移动到reposB/dirAA/下,本来打算交给SA做,没想到SA似乎 也不太懂的样子.于是,自己在VPS搭建了一个svnserve ...
- 服务器为什么这么慢?耗尽了CPU、RAM和磁盘I/O资源
机器运行缓慢通常是由于消耗了太多系统特定的资源.系统的主要资源包括CPU.RAM.磁盘I/O以及网络.过度使用这些资源的任何一种都会让系统陷入困境.不过,如果能登录到系统之中,可以借助大量工具确定问题 ...
- 第1章 1.7计算机网络概述--理解OSI参考模型分层思想
OSI七层模型,知识参考理论. 分层标准的好处: 1.不同的硬件生产商生产的硬件产品,连通后就可以用了,有助于互联网发展. 2.分层,分成不同的模块,某一层的变化,不会影响其他层.如:IPv4改为IP ...
- python-pdf添加水印
0.用到两个扩展模块:ReportLab.PyPDF2. 1.创建水印PDF. 1).创建文字水印pdf文件 代码: #encoding=utf-8 #author: walker #date: 20 ...
- android 百度地图 No implementation found for int
java.lang.UnsatisfiedLinkError: No implementation found for int com.baidu.platform.comjni.map.common ...
- DrawLayout使用侧滑抽屉
布局:fg_left_drawer <?xml version="1.0" encoding="utf-8"?> <LinearLayout ...
- drawable转mitmap 以及图片base64编码
static Bitmap drawableToBitmap(Drawable drawable) // drawable 转换成bitmap { int width = drawable.getIn ...
- KS检验学习[转载]
转自:https://wenku.baidu.com/view/ccfa573a3968011ca30091d6.html https://www.cnblogs.com/arkenstone/p/5 ...
- hashset和treeset的区别
hashset 和 treeset的区别 hashset 和 treeset的区别 1.TreeSet 是二差树实现的,Treeset中的数据是自动排好序的,不允许放入null值. 2.HashSet ...