【POJ 2352】 Stars
【题目链接】
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的更多相关文章
- 【POJ 2482】 Stars in Your Window(线段树+离散化+扫描线)
[POJ 2482] Stars in Your Window(线段树+离散化+扫描线) Time Limit: 1000MS Memory Limit: 65536K Total Submiss ...
- 【POJ 2482】 Stars in Your Windows
[题目链接] http://poj.org/problem?id=2482 [算法] 线段树 + 扫描线 [代码] #include <algorithm> #include <bi ...
- 【POJ 2482】Stars in Your Window
http://poj.org/problem?id=2482 线段树扫描线 #include<cstdio> #include<cstring> #include<alg ...
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
- 【链表】BZOJ 2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 382 Solved: 111[Submit][S ...
- BZOJ2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 284 Solved: 82[Submit][St ...
- BZOJ2293: 【POJ Challenge】吉他英雄
2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 80 Solved: 59[Submit][Stat ...
- BZOJ2287: 【POJ Challenge】消失之物
2287: [POJ Challenge]消失之物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 254 Solved: 140[Submit][S ...
- BZOJ2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 126 Solved: 90[Submit][Sta ...
随机推荐
- 利用jquery的ajaxPrefilter阻止重复发送请求
利用jquery的ajaxPrefilter阻止重复发送请求 (function ($) { var pendingRequests = {}; // 所有ajax请求的通用前置filter $.aj ...
- 性能问题解决案例01——sybase数据库内存问题
最近湖南现场反馈问题,所有电子签章页面打不开文书(pdf格式),后台日志没报任何错误. 1.首先想到是签章的ocx控件问题,检查ocx控件安装,发现其他电脑也打不开文书,测试页面可以直接打开pdf文档 ...
- Python基础:使用list & tuple
list Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. tuple 小结 list和tuple是Python内置的有序集合,一个可变,一个不 ...
- JS 实现1!+2!+3!+4!+5!+....+n!
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Nginx+Php-fpm运行原理
一.代理与反向代理 现实生活中的例子 1.正向代理:访问google.com 如上图,因为google被墙,我们需要vpnFQ才能访问google.com. vpn对于“我们”来说,是可以感知到的(我 ...
- nginx (待更新)
install apt install nginx 默认在 /etc/nginx 目录下 一个 master 以及多个 worker 3504 root 20 0 141M 7196 5552 S 0 ...
- Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)A. Friends Meeting
Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the ...
- Flex简易教程
常见的前端布局模型涵盖浮动.定位和弹性盒等 CSS 技术,其中浮动和定位技术往往在制作自适应布局页面时显得不够优雅--对于浮动布局,前后端分离时代很多时候我们并不知道每行会遍历显示多少个元素,每个 ...
- Project Euler 35 Circular primes
题意:197被称为圆周素数,因为将它逐位旋转所得到的数:197/971和719都是素数.小于100的圆周素数有十三个:2.3.5.7.11.13.17.31.37.71.73.79和97.小于一百万的 ...
- nginx 301 重定向设置不含www到www域名
如果需要将不含www主机的域名301重定向到含www的域名,如将 shwww.net 重定向至 www.shwww.net,nginx 配置指令如下: server { server_name shw ...