【题目链接】

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. 大数字运算——2、BigDecimal

    package com.wh.BigInteger; import java.math.BigDecimal; import java.util.Arrays; /** * @author 王恒 * ...

  2. 详解DevExpress.LookUpEdit控件实现自动搜索定位功能(转)

    转载自csdn博客 爱拼才会赢 的博客 地址是详解DevExpress.LookUpEdit控件实现自动搜索定位功能(转)

  3. python 微信红包

    def redbags(money, num=10): import random choice = random.sample(range(1, money * 100), num - 1) cho ...

  4. [转]Java设计模式学习心得

    http://tech.it168.com/focus/200902/java-design/index.html http://tech.it168.com/j/2007-05-17/2007051 ...

  5. css3 边框、背景、文本效果

    浅玩CSS3 边框.背景.文本效果 一.边框 box-shadow box-shadow: h-shadow v-shadow blur spread color inset(ontset); //h ...

  6. 使用Storm实现实时大数据分析!

    随着数据体积的越来越大,实时处理成为了许多机构需要面对的首要挑战.Shruthi Kumar和Siddharth Patankar在Dr.Dobb's上结合了汽车超速监视,为我们演示了使用Storm进 ...

  7. AI:**消灭程序员需要一百年吗?

    这篇博文真的很长,不过挺有意思.关于智能机器人的发展前景还是很广的,因为每一步都异常艰难,而什么时候可以终止还无法预料,所以程序员没办法失业啊! 转自于图灵社区:http://www.ituring. ...

  8. 关于dlg和pro的问题

    微软链接:http://technet.microsoft.com/zh-cn/subscriptions/bb983387.aspx CDialogEx::CDialogEx 构造 CDialogE ...

  9. ES : 软件工程学的复杂度理论及物理学解释

    系统论里面总是有一些通用的专业术语 比如复杂度.熵.焓,复杂度专门独立出来,成为复杂度理论 文章摘抄于:<非线性动力学> 刘秉政 编著  5.5 复杂性及其测度 热力学的几个专业术语 熵. ...

  10. Spring cloud服务的提供者建立

    1.0我们要在这里要建立一个服务的提供者模块,是一个module,类似于服务的公共模块 第一步:添加架包 <project xmlns="http://maven.apache.org ...