POJ-2029 Get Many Persimmon Trees---二维树状数组+枚举
题目链接:
https://vjudge.net/problem/POJ-2029
题目大意:
有N棵树在一个n*m的田里,给出每颗树的坐标
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
#define lowbot(i) (i&(-i))
using namespace std;
typedef long long ll;
const int maxn = + ;
int n, m, T, k, cases;
int tree[maxn][maxn];
void add(int x, int y, int d)
{
for(int i = x; i <= n; i += lowbot(i))
{
for(int j = y; j <= m; j += lowbot(j))
{
tree[i][j] += d;
}
}
}
int sum(int x, int y)
{
int ans = ;
for(int i = x; i > ; i -= lowbot(i))
{
for(int j = y; j > ; j -= lowbot(j))
{
ans += tree[i][j];
}
}
return ans;
}
int Sum(int x1, int y1, int x2, int y2)
{
return sum(x2, y2) + sum(x1 - , y1 - ) - sum(x1 - , y2) - sum(x2, y1 - );
}
int main()
{
while(cin >> k && k)
{
int x, y, s, t;
memset(tree, , sizeof(tree));
cin >> n >> m;
while(k--)
{
scanf("%d%d", &x, &y);
add(x, y, );
}
cin >> s >> t;
int ans = ;
for(int i = ; i + s - <= n; i++)
{
for(int j = ; j + t - <= m; j++)
{
int tot = Sum(i, j, i + s - , j + t - );
ans = max(ans, tot);
}
}
cout<<ans<<endl;
}
return ;
}
POJ-2029 Get Many Persimmon Trees---二维树状数组+枚举的更多相关文章
- POJ2029:Get Many Persimmon Trees(二维树状数组)
Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aiz ...
- [poj2155]Matrix(二维树状数组)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 25004 Accepted: 9261 Descripti ...
- 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(DP||二维树状数组)
题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio ...
- POJ 2029 Get Many Persimmon Trees (模板题)【二维树状数组】
<题目链接> 题目大意: 给你一个H*W的矩阵,再告诉你有n个坐标有点,问你一个w*h的小矩阵最多能够包括多少个点. 解题分析:二维树状数组模板题. #include <cstdio ...
- POJ 2029 (二维树状数组)题解
思路: 大力出奇迹,先用二维树状数组存,然后暴力枚举 算某个矩形区域的值的示意图如下,代码在下面慢慢找... 代码: #include<cstdio> #include<map> ...
- Get Many Persimmon Trees_枚举&&二维树状数组
Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aiz ...
- poj 1195:Mobile phones(二维树状数组,矩阵求和)
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14489 Accepted: 6735 De ...
- POJ 2155 Matrix【二维树状数组+YY(区间计数)】
题目链接:http://poj.org/problem?id=2155 Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissio ...
- POJ 2155 Matrix(二维树状数组,绝对具体)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 20599 Accepted: 7673 Descripti ...
随机推荐
- Clover笔记
1. Clover传参 a. jobflow传到子graph(GraphParameters): 设值: 用全局GraphParameters传递,在ExecuteGraph中的output mapp ...
- php composer php amqplib
下载composer.phar放到项目根目录 d:/www/apps https://getcomposer.org/download/1.4.1/composer.phar 下载安装Composer ...
- 微信小程序多图上传/朋友圈传图效果【附完整源码】
效果图 部分源代码 js文件: var uploadPicture = require('../Frameworks/common.js') //获取应用实例 const app = getApp() ...
- logback日志简记
%date{HH:mm:ss.SSS} [%thread] %-5level %logger{20}:%line - %msg%n 输出: 09:54:09.657 [main] INFO c.e. ...
- my.常用的话
1. 60普通副本+++ 60普通副本+++ 60普通副本+++ 50封妖+++50封妖+++50封妖+++ 60一本十妖+++ 60一本十妖+++ 60一本十妖+++ 60封妖+++60封妖+++6 ...
- my.资料_副本_破六欲
http://www.nok2.com/fxjy/816.html 梦幻之家礼包网讲解梦幻2破除心魔 来源:www.nok2.com作者:礼包达人时间:2016-04-01 22:11 最近听到不少小 ...
- 转 Python 多进程multiprocessing.Process之satrt()和join()
1. https://blog.csdn.net/wonengguwozai/article/details/80325745 今天项目中涉及到了使用多进程处理数据,在廖雪峰的python教程上学习了 ...
- swagger demo code
//Application 开启注解 @EnableSwagger2public class Application { public static void main(String[] args) ...
- Visio Studio使用总结
1.常用快捷键: 注释:Ctrl+K+C 取消注释:Ctrl+K+U 增加缩进:Table 减少缩进: Table+Shift 格式化文本:A. Ctrl+K+F(选中文本) B. Ctrl+K ...
- Ordering Tasks UVA - 10305(拓扑排序)
在一个有向图中,对所有的节点进行排序,要求没有一个节点指向它前面的节点. 先统计所有节点的入度,对于入度为0的节点就可以分离出来,然后把这个节点指向的节点的入度减一. 一直做改操作,直到所有的节点都被 ...