思路:简单树状数组

  1. #include<map>
  2. #include<set>
  3. #include<cmath>
  4. #include<queue>
  5. #include<cstdio>
  6. #include<vector>
  7. #include<string>
  8. #include<cstdlib>
  9. #include<cstring>
  10. #include<iostream>
  11. #include<algorithm>
  12. #define pb push_back
  13. #define mp make_pair
  14. #define Maxn 120
  15. #define Maxm 80002
  16. #define LL __int64
  17. #define Abs(x) ((x)>0?(x):(-x))
  18. #define lson(x) (x<<1)
  19. #define rson(x) (x<<1|1)
  20. #define inf 0x7fffffff
  21. #define lowbit(x) (x&(-x))
  22. #define Mod 1000000007
  23. using namespace std;
  24. int c[Maxn][Maxn],w,h,n;
  25. void update(int x,int y)
  26. {
  27. int yy=y;
  28. while(x<=w){
  29. y=yy;
  30. while(y<=h){
  31. c[x][y]++;
  32. y+=lowbit(y);
  33. }
  34. x+=lowbit(x);
  35. }
  36. }
  37. int sum(int x,int y)
  38. {
  39. int sum=,yy=y;
  40. while(x){
  41. y=yy;
  42. while(y){
  43. sum+=c[x][y];
  44. y-=lowbit(y);
  45. }
  46. x-=lowbit(x);
  47. }
  48. return sum;
  49. }
  50. int main()
  51. {
  52. int n,i,j,x,y;
  53. while(scanf("%d",&n)!=EOF,n){
  54. memset(c,,sizeof(c));
  55. scanf("%d%d",&w,&h);
  56. for(i=;i<=n;i++){
  57. scanf("%d%d",&x,&y);
  58. update(x,y);
  59. }
  60. scanf("%d%d",&x,&y);
  61. int ans=;
  62. for(i=x;i<=w;i++){
  63. for(j=y;j<=h;j++){
  64. ans=max(ans,sum(i,j)-sum(i-x,j)-sum(i,j-y)+sum(i-x,j-y));
  65. }
  66. }
  67. printf("%d\n",ans);
  68. }
  69. return ;
  70. }

poj 2029 二维树状数组的更多相关文章

  1. POJ 1195 二维树状数组

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 18489   Accepted: 8558 De ...

  2. poj 3378 二维树状数组

    思路:直接用long long 保存会WA.用下高精度加法就行了. #include<map> #include<set> #include<cmath> #inc ...

  3. poj 2155 (二维树状数组 区间修改 求某点值)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 33682   Accepted: 12194 Descript ...

  4. Mobile phones POJ - 1195 二维树状数组求和

    Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...

  5. POJ 2029 Get Many Persimmon Trees (二维树状数组)

    Get Many Persimmon Trees Time Limit:1000MS    Memory Limit:30000KB    64bit IO Format:%I64d & %I ...

  6. POJ 2029 Get Many Persimmon Trees(DP||二维树状数组)

    题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio ...

  7. POJ 2029 Get Many Persimmon Trees (模板题)【二维树状数组】

    <题目链接> 题目大意: 给你一个H*W的矩阵,再告诉你有n个坐标有点,问你一个w*h的小矩阵最多能够包括多少个点. 解题分析:二维树状数组模板题. #include <cstdio ...

  8. POJ 2029 (二维树状数组)题解

    思路: 大力出奇迹,先用二维树状数组存,然后暴力枚举 算某个矩形区域的值的示意图如下,代码在下面慢慢找... 代码: #include<cstdio> #include<map> ...

  9. poj 1195:Mobile phones(二维树状数组,矩阵求和)

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14489   Accepted: 6735 De ...

随机推荐

  1. vss使用详解

    下面已VSS6.0为主: 一:安装VSS6.0 安装过程中可能会提示 退出,禁止(abort)  重试(retry)  忽略,跳过(Ignore)  ,我们选 Ignore  跳过此项, 路径自己选择 ...

  2. SQL语句 & 查询表结构

    [group by] 对结果集进行分组,常与汇总函数一起使用. SELECT column,SUM(column) FROM table GROUP BY column HAVING 通常与 GROU ...

  3. SQL SERVER:开窗函数 SUM() OVER() 数据统计中一例使用

    由于前一段时间胃痛,导致博客园博客都停更了一个月左右.近几天,胃病终于稍微有所好转,决定重新写博文. 前几天,有个朋友刚好问到本人有关 SQL 语句,大致是原表有两列,分别为月份.月份销售额,而需要一 ...

  4. Android Fragment详解

    一.什么是Fragment Android在3.0中引入了fragments的概念,主要目的是用在大屏幕设备上--例如平板电脑上,支持更加动态和灵活的UI设计.平板电脑的屏幕要比手机的大得多,有更多的 ...

  5. 【转】Python字符编码详解

    转自:http://www.cnblogs.com/huxi/archive/2010/12/05/1897271.html 1. 字符编码简介 1.1. ASCII ASCII(American S ...

  6. COM组件入门(一)

    近期须要用到COM组件的知识,看了看COM编程指南,感觉还不错.把我的学习心得记录下来.这是我依据教程写的demo StopWatch接口实现部分,接口部分我的项目是动态库,主要源代码例如以下: 完整 ...

  7. 试读《基于MVC的JavaScript Web富应用开发》

    前两年做jsp开发时,用了不少JavaScript(JS)和Ajax, 最近的项目一直在使用Flex做前台,虽然也有类似的ActionScript实现JS的功能,但没想到的是,短短几年JS发展如此迅速 ...

  8. Android+Jquery Mobile学习系列(4)-页面跳转及参数传递

    关于页面转场,这个必须得专门列出来说明一下,因为Jquery Mobile与普通的Web发开有一些区别,这个对于新手如果不了解的话,就会钻到死胡同.撸主前段时间就是很急躁地上手开发程序,结果在页面转场 ...

  9. 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 ...

  10. 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 ...