poj 2029 二维树状数组
思路:简单树状数组
- #include<map>
- #include<set>
- #include<cmath>
- #include<queue>
- #include<cstdio>
- #include<vector>
- #include<string>
- #include<cstdlib>
- #include<cstring>
- #include<iostream>
- #include<algorithm>
- #define pb push_back
- #define mp make_pair
- #define Maxn 120
- #define Maxm 80002
- #define LL __int64
- #define Abs(x) ((x)>0?(x):(-x))
- #define lson(x) (x<<1)
- #define rson(x) (x<<1|1)
- #define inf 0x7fffffff
- #define lowbit(x) (x&(-x))
- #define Mod 1000000007
- using namespace std;
- int c[Maxn][Maxn],w,h,n;
- void update(int x,int y)
- {
- int yy=y;
- while(x<=w){
- y=yy;
- while(y<=h){
- c[x][y]++;
- y+=lowbit(y);
- }
- x+=lowbit(x);
- }
- }
- int sum(int x,int y)
- {
- int sum=,yy=y;
- while(x){
- y=yy;
- while(y){
- sum+=c[x][y];
- y-=lowbit(y);
- }
- x-=lowbit(x);
- }
- return sum;
- }
- int main()
- {
- int n,i,j,x,y;
- while(scanf("%d",&n)!=EOF,n){
- memset(c,,sizeof(c));
- scanf("%d%d",&w,&h);
- for(i=;i<=n;i++){
- scanf("%d%d",&x,&y);
- update(x,y);
- }
- scanf("%d%d",&x,&y);
- int ans=;
- for(i=x;i<=w;i++){
- for(j=y;j<=h;j++){
- ans=max(ans,sum(i,j)-sum(i-x,j)-sum(i,j-y)+sum(i-x,j-y));
- }
- }
- printf("%d\n",ans);
- }
- return ;
- }
poj 2029 二维树状数组的更多相关文章
- POJ 1195 二维树状数组
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 18489 Accepted: 8558 De ...
- poj 3378 二维树状数组
思路:直接用long long 保存会WA.用下高精度加法就行了. #include<map> #include<set> #include<cmath> #inc ...
- poj 2155 (二维树状数组 区间修改 求某点值)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 33682 Accepted: 12194 Descript ...
- Mobile phones POJ - 1195 二维树状数组求和
Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...
- 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> ...
- poj 1195:Mobile phones(二维树状数组,矩阵求和)
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14489 Accepted: 6735 De ...
随机推荐
- vss使用详解
下面已VSS6.0为主: 一:安装VSS6.0 安装过程中可能会提示 退出,禁止(abort) 重试(retry) 忽略,跳过(Ignore) ,我们选 Ignore 跳过此项, 路径自己选择 ...
- SQL语句 & 查询表结构
[group by] 对结果集进行分组,常与汇总函数一起使用. SELECT column,SUM(column) FROM table GROUP BY column HAVING 通常与 GROU ...
- SQL SERVER:开窗函数 SUM() OVER() 数据统计中一例使用
由于前一段时间胃痛,导致博客园博客都停更了一个月左右.近几天,胃病终于稍微有所好转,决定重新写博文. 前几天,有个朋友刚好问到本人有关 SQL 语句,大致是原表有两列,分别为月份.月份销售额,而需要一 ...
- Android Fragment详解
一.什么是Fragment Android在3.0中引入了fragments的概念,主要目的是用在大屏幕设备上--例如平板电脑上,支持更加动态和灵活的UI设计.平板电脑的屏幕要比手机的大得多,有更多的 ...
- 【转】Python字符编码详解
转自:http://www.cnblogs.com/huxi/archive/2010/12/05/1897271.html 1. 字符编码简介 1.1. ASCII ASCII(American S ...
- COM组件入门(一)
近期须要用到COM组件的知识,看了看COM编程指南,感觉还不错.把我的学习心得记录下来.这是我依据教程写的demo StopWatch接口实现部分,接口部分我的项目是动态库,主要源代码例如以下: 完整 ...
- 试读《基于MVC的JavaScript Web富应用开发》
前两年做jsp开发时,用了不少JavaScript(JS)和Ajax, 最近的项目一直在使用Flex做前台,虽然也有类似的ActionScript实现JS的功能,但没想到的是,短短几年JS发展如此迅速 ...
- Android+Jquery Mobile学习系列(4)-页面跳转及参数传递
关于页面转场,这个必须得专门列出来说明一下,因为Jquery Mobile与普通的Web发开有一些区别,这个对于新手如果不了解的话,就会钻到死胡同.撸主前段时间就是很急躁地上手开发程序,结果在页面转场 ...
- Codeforces Round #290 (Div. 2) B. Fox And Two Dots dfs
B. Fox And Two Dots 题目连接: http://codeforces.com/contest/510/problem/B Description Fox Ciel is playin ...
- Codeforces Round #306 (Div. 2) A. Two Substrings 水题
A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...