【题目链接】

http://poj.org/problem?id=2352

【算法】

树状数组

注意x坐标为0的情况

【代码】

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std;
#define MAXN 50010 struct info
{
int x,y;
} a[MAXN]; int i,n;
int ans[MAXN]; struct BinaryIndexedTree
{
int c[MAXN];
inline int lowbit(int x)
{
return x & (-x);
}
inline void modify(int pos,int val)
{
int i;
for (i = pos; i < MAXN; i += lowbit(i)) c[i] += val;
}
inline int query(int pos)
{
int i;
int ret = ;
for (i = pos; i; i -= lowbit(i))
ret += c[i];
return ret;
}
} BIT; int main()
{ scanf("%d",&n);
for (i = ; i <= n; i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
a[i].x++; a[i].y++;
}
for (i = ; i <= n; i++)
{
ans[BIT.query(a[i].x)]++;
BIT.modify(a[i].x,);
}
for (i = ; i < n; i++) printf("%d\n",ans[i]); return ; }

【POJ 2352】 Stars的更多相关文章

  1. 【POJ 2482】 Stars in Your Window(线段树+离散化+扫描线)

    [POJ 2482] Stars in Your Window(线段树+离散化+扫描线) Time Limit: 1000MS   Memory Limit: 65536K Total Submiss ...

  2. 【POJ 2482】 Stars in Your Windows

    [题目链接] http://poj.org/problem?id=2482 [算法] 线段树 + 扫描线 [代码] #include <algorithm> #include <bi ...

  3. 【POJ 2482】Stars in Your Window

    http://poj.org/problem?id=2482 线段树扫描线 #include<cstdio> #include<cstring> #include<alg ...

  4. bzoj 2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...

  5. 【链表】BZOJ 2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 382  Solved: 111[Submit][S ...

  6. BZOJ2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 284  Solved: 82[Submit][St ...

  7. BZOJ2293: 【POJ Challenge】吉他英雄

    2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 80  Solved: 59[Submit][Stat ...

  8. BZOJ2287: 【POJ Challenge】消失之物

    2287: [POJ Challenge]消失之物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 254  Solved: 140[Submit][S ...

  9. BZOJ2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 126  Solved: 90[Submit][Sta ...

随机推荐

  1. Web启动,停止Windows服务

    When you grow stronger,the world become more dangerous.当你变得越强大,这个世界反而会变得越危险. ServiceModel.cs代码: publ ...

  2. 【android】RxJava1原理解析

    在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...

  3. hiho一下 第173周

    题目1 : A Game 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi and Little Ho are playing a game. Ther ...

  4. Css float 盒子模型 position

    属性: float 浮动 浮动的内容用div包起来,给div设置宽高 clear 清除浮动. box-sizing 标准模式下的盒模型 content-box:(默认属性) padding和borde ...

  5. Java集合(一)HashMap

    HashMap 特点: HashMap的key和value都允许为空,无序的,且非线程安全的 数据结构: HashMap底层是一个数组,数组的每一项又都是链表,即数据和链表的结合体.当新建一个Hash ...

  6. Tomcat 报错 记录

    Resource is out of sync with the file system: 该错误为替换了image中的图片而没有进行更新,造成找不到该资源,进而保存,解决只要eclipse刷新一下F ...

  7. (转载)自定义CoordinatorLayout的Behavior(2):实现淘宝和QQ ToolBar透明渐变效果

    自定义CoordinatorLayout的Behavior(2):实现淘宝和QQ ToolBar透明渐变效果 作者 小武站台 关注 2016.02.19 11:34 字数 1244 阅读 3885评论 ...

  8. 用Navicat自动备份mysql数据库

    以下文章转载自https://blog.csdn.net/u013628152/article/details/54909885,放在自己的博客园以供后面方便查询 —————————————————— ...

  9. python版本及ML库

    一:关于Python版本的选择问题 关于Python的选择问题:要看学术界能不能把科学库迁移到Python3. 1:多个版本共用: 最近发现SciPy的最高版本是3.2,只能是退而求其次,不使用最新版 ...

  10. 六星经典CSAPP笔记系列 - 作者:西代零零发

    六星经典CSAPP笔记(1)计算机系统巡游 六星经典CSAPP笔记(2)信息的操作和表示 六星经典CSAPP-笔记(3)程序的机器级表示