poj 2029 Get Many Persimmon Trees 【二维树状数组】
来源:互联网 发布:stc8 串口发送数据 编辑:程序博客网 时间:2024/05/16 01:09
题目链接:poj 2029 Get Many Persimmon Trees
题意:在
暴力枚举右端点。
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <algorithm>#include <vector>#include <queue>#include <map>#include <stack>#define PI acos(-1.0)#define CLR(a, b) memset(a, (b), sizeof(a))#define fi first#define se second#define ll o<<1#define rr o<<1|1using namespace std;typedef long long LL;typedef pair<int, int> pii;const int MAXN = 500 + 10;const int pN = 1e6;// <= 10^7const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;void add(LL &x, LL y) { x += y; x %= MOD; }int C[MAXN][MAXN];int H, W;int lowbit(int x) { return x & (-x);}void add(int x, int y, int d) { while(x <= W) { int sy = y; while(sy <= H) { C[x][sy] += d; sy += lowbit(sy); } x += lowbit(x); }}int Sum(int x, int y) { int s = 0; while(x > 0) { int sy = y; while(sy > 0) { s += C[x][sy]; sy -= lowbit(sy); } x -= lowbit(x); } return s;}int S, T;int Get(int x, int y) { int x1 = max(1, x - S + 1), y1 = max(1, y - T + 1); return Sum(x, y) + Sum(x1-1, y1-1) - Sum(x, y1-1) - Sum(x1-1, y);}int main(){ int N; while(scanf("%d", &N), N) { CLR(C, 0); scanf("%d%d", &W, &H); while(N--) { int x, y; scanf("%d%d", &x, &y); add(x, y, 1); } scanf("%d%d", &S, &T); int ans = 0; for(int i = S; i <= W; i++) { for(int j = T; j <= H; j++) { ans = max(ans, Get(i, j)); } } printf("%d\n", ans); } return 0;}
0 0
- poj 2029 Get Many Persimmon Trees 二维树状数组
- POJ 2029 Get Many Persimmon Trees(二维树状数组)
- POJ 2029 Get Many Persimmon Trees 二维树状数组
- poj 2029 Get Many Persimmon Trees 二维树状数组 大水
- poj 2029 Get Many Persimmon Trees(二维树状数组)
- poj 2029 Get Many Persimmon Trees (二维树状数组)
- Poj 2029 Get Many Persimmon Trees 二维树状数组
- POJ 2029 Get Many Persimmon Trees (二维树状数组)
- poj 2029 Get Many Persimmon Trees 二维树状数组
- poj 2029 Get Many Persimmon Trees 【二维树状数组】
- POJ 2029 Get Many Persimmon Trees(二维树状数组)
- (POJ 2029)Get Many Persimmon Trees <二维树状数组>
- poj 2029 Get Many Persimmon Trees 二维树状数组
- 【树状数组--二维】poj 2029 Get Many Persimmon Trees
- [树状数组] poj 2029 Get Many Persimmon Trees#裸的二维树状数组
- POJ 2029 Get Many Persimmon Trees DP/二维树状数组/线段树
- POJ 2029 Get Many Persimmon Trees 二维树状数组(水)
- POJ 2029 Get Many Persimmon Trees (二维树状数组 or DP)
- java 为什么使用工厂方法设计模式
- R 语言介绍
- HDU 5615:Jam's math problem【模拟】
- 键盘通知和自定义键盘
- hosts的简介
- poj 2029 Get Many Persimmon Trees 【二维树状数组】
- #去掉“No SIM Card Installed”提示
- 如何解决Mongodb内存过大问题
- 项目之IC卡程序
- Java 判断文件夹、文件是否存在、否则创建文件夹
- Delegate
- JPEG 原理详细实例分析及其在嵌入式 Linux 中的应用
- C++中类的大小
- 在eclipse中新建java项目缺少相关jar包的问题解决