POJ2029 Get Many Persimmon Trees
来源:互联网 发布:java中的string 编辑:程序博客网 时间:2024/05/16 00:37
题目链接:http://poj.org/problem?id=2029
二维树状数组+容斥
c[i][j]的意义是(i,j)为右下角的前缀和
注意要向上统计,向下修改
注意区别单点修改与区间修改
贴代码
#include<cstdio>#include<cstring>using namespace std;int const maxn=105;int c[maxn][maxn];int n,w,h;int lowbit(int x){return x&-x;}void add(int x,int y){for (int i=x;i<=w;i+=lowbit(i))for (int j=y;j<=h;j+=lowbit(j))c[i][j]+=1;}int query(int x,int y){int sum=0;for (int i=x;i>=1;i-=lowbit(i))for (int j=y;j>=1;j-=lowbit(j))sum+=c[i][j];return sum;}int max(int x,int y){return x>y?x:y;}int main(){//freopen("2029.in","r",stdin);//freopen("2029.out","w",stdout);scanf("%d",&n);while (n){scanf("%d%d",&w,&h);w++;h++;memset(c,0,sizeof(c));while (n--){int x,y;scanf("%d%d",&x,&y);x++;y++;add(x,y);}int s,t;scanf("%d%d",&s,&t);int ans=0;for (int i=s+1;i<=w;i++)for (int j=t+1;j<=h;j++) ans=max(ans,query(i,j)-query(i-s,j)-query(i,j-t)+query(i-s,j-t));printf("%d\n",ans);scanf("%d",&n);}return 0;}【写的有漏洞的,欢迎路过大神吐槽】
2017/07/06 22:03:04
Ending.
阅读全文
0 0
- poj2029 Get Many Persimmon Trees
- POJ2029--Get Many Persimmon Trees
- poj2029 Get Many Persimmon Trees
- poj2029 Get Many Persimmon Trees
- POJ2029 Get Many Persimmon Trees
- poj2029 Get Many Persimmon Trees
- POJ2029——Get Many Persimmon Trees
- poj2029--Get Many Persimmon Trees(dp)
- POJ2029 Get Many Persimmon Trees(树状数组~)
- POJ2029:Get Many Persimmon Trees(DP)
- POJ2029--Get Many Persimmon Trees(枚举+二维树状数组)
- POJ2029:Get Many Persimmon Trees(二维树状数组)
- pku2029 Get Many Persimmon Trees
- zoj1716 Get Many Persimmon Trees
- zoj1716 Get Many Persimmon Trees
- POJ 2029 Get Many Persimmon Trees
- Poj 2029 Get Many Persimmon Trees
- POJ 2029 Get Many Persimmon Trees [dp]
- oauth
- FSL配置GPU环境运行bedpostx以及probtrackx
- DBuitls驼峰规则
- linux安装ftp配置
- Html5与Css3布局、盒模型(七)
- POJ2029 Get Many Persimmon Trees
- 浮动相关的细细碎碎
- 葵花宝典 十八 内置对象
- hough变换直线方程推导
- B
- BZOJ: [POI2008]激光发射器SZK 题解
- 关注民生民情——华北水利水电大学“情艺”龙湖社区调查(二)
- Vuforia Object Scanner 使用
- 纯干货10 强化学习视频教程分享(从入门到精通)