(简单) POJ 2352 Stars,Treap。
2015-07-17 15:27
190 查看
Description
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the stars.
View Code
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the stars.
// ━━━━━━神兽出没━━━━━━ // ┏┓ ┏┓ // ┏┛┻━━━━━━━┛┻┓ // ┃ ┃ // ┃ ━ ┃ // ████━████ ┃ // ┃ ┃ // ┃ ┻ ┃ // ┃ ┃ // ┗━┓ ┏━┛ // ┃ ┃ // ┃ ┃ // ┃ ┗━━━┓ // ┃ ┣┓ // ┃ ┏┛ // ┗┓┓┏━━━━━┳┓┏┛ // ┃┫┫ ┃┫┫ // ┗┻┛ ┗┻┛ // // ━━━━━━感觉萌萌哒━━━━━━ // Author : WhyWhy // Created Time : 2015年07月17日 星期五 14时44分13秒 // File Name : 1195.cpp #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <time.h> using namespace std; const int MaxN=1100; int C[MaxN][MaxN]; int N; inline int lowbit(int x) { return x&(-x); } void add(int x,int y,int d) { int t; while(x<=N) { t=y; while(t<=N) { C[x][t]+=d; t+=lowbit(t); } x+=lowbit(x); } } int query(int x,int y) { int ret=0; int t; while(x>0) { t=y; while(t>0) { ret+=C[x][t]; t-=lowbit(t); } x-=lowbit(x); } return ret; } int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int a,b,c,d,e; while(1) { scanf("%d",&a); if(a==1) { scanf("%d %d %d",&b,&c,&d); add(b+1,c+1,d); } else if(a==2) { scanf("%d %d %d %d",&b,&c,&d,&e); printf("%d\n",query(d+1,e+1)-query(d+1,c)-query(b,e+1)+query(b,c)); } else if(a==0) { scanf("%d",&N); memset(C,0,sizeof(C)); } else break; } return 0; }
View Code
相关文章推荐
- Redis缓存数据库介绍与环境搭建
- centos下sentinel主从监控配置
- 收藏网站
- iOS9编程GOGOGO:XCode7新变化
- 关于PO,POJO,VO
- Learning WCF Chapter1 Summary
- 问题-[Delphi]断点后怎么设置条件
- form中的get 与post简单对比 转
- pom.xml的配置详解
- HDU 3016 线段树区间更新+spfa
- 输入一串数字找出其中缺少的最小的两个数
- iOS开源项目 Cell滑动效果
- 缘语言 V1.1 发布!
- 报错,但不影响运行ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
- javascript中对变量类型的判断
- WatchKit开发技巧
- poj1724--ROADS(最短路变形)
- 活动安排-动态规划算法
- HashMap的实现原理
- 响应客户端请求(servlet与jsp)