UESTC 1584
http://acm.uestc.edu.cn/#/problem/show/1584
Washi与Sonochi的约定
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 131072/131072KB (Java/Others)
Submit Status
Sonochi,明年再一起看烟花。——WashioSumi

为了实现和Sonochi的约定,Washi必须要打败眼前强大的怪物。
怪物分布在二维平面上,
某个怪物的rank被定义为x坐标不大于其x坐标,且y坐标不大于其y坐标的怪物的数量。(不含其自身)
Washi要你输出n行,每行一个整数,分别代表rank为0~n−1的怪物数量。
Input
输入第一行为一个正整数n,
接下来n行,第ii行两个整数xi、yi,表示一个怪物的坐标。
保证输入的坐标两两不同。
Output
包含n行,每行一个整数,第ii行的数代表rank为i−1i−1的怪物数量
Sample Input Sample Output
5
1 1
5 1
7 1
3 3
5 5
1
2
1
1
0
Hint
1≤n≤100000
1≤xi≤100000
1≤yi≤100000
树状数组+排序
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int ran[];
int vis[],n;
struct Node
{
int x,y;
}node[];
bool cmp(const Node &a,const Node &b)
{
if(a.x!=b.x) return a.x<b.x;
else return a.y<b.y;
}
int main()
{
scanf("%d",&n);
memset(vis,,sizeof(vis));
memset(vis,,sizeof(ran));
for(int i=;i<n;i++)
{
scanf("%d%d",&node[i].x,&node[i].y);
}
sort(node,node+n,cmp);
for(int i=;i<n;i++)
{
int ans=;
for(int j=node[i].y;j;j-=(j&-j))
ans+=vis[j];
ran[ans]++;
for(int j=node[i].y;j<;j+=(j&-j))
vis[j]++;
}
for(int i=;i<n;i++)
{
printf("%d\n",ran[i]);
}
return ;
}
UESTC 1584的更多相关文章
- UESTC 1584 Washi与Sonochi的约定【树状数组裸题+排序】
题目链接:UESTC 1584 Washi与Sonochi的约定 题意:在二维平面上,某个点的ranked被定义为x坐标不大于其x坐标,且y坐标不大于其y坐标的怪物的数量.(不含其自身),要求输出n行 ...
- 2017ecjtu-summer training #4 UESTC 1584
此题链接 http://acm.uestc.edu.cn/#/problem/show/1584 此题和hdu1541几乎完全一样,我们要先对坐标排序,再进行操作. hdu1541题解 http:// ...
- ACM:UESTC - 649 括号配对问题 - stack
UESTC - 649 括号配对问题 Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & %llu ...
- UESTC 1015 Lweb and pepper --前,后缀最值
题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...
- UESTC 1852 Traveling Cellsperson
找规律水题... Traveling Cellsperson Time Limit: 1000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 1851 Kings on a Chessboard
状压DP... Kings on a Chessboard Time Limit: 10000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 30 最短路,floyd,水
最短路 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Statu ...
- UVa 1584 Circular Sequence --- 水题
UVa 1584 题目大意:给定一个含有n个字母的环状字符串,可从任意位置开始按顺时针读取n个字母,输出其中字典序最小的结果 解题思路:先利用模运算实现一个判定给定一个环状的串以及两个首字母位置,比较 ...
- uestc oj 1218 Pick The Sticks (01背包变形)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...
随机推荐
- GenIcam标准(二)
2 GenApi模块 – 配置相机 2.1. 简介 GenApi模块解决如何去配置相机的问题.主要的思路是,让相机生产厂商为他们的相机提供机器可以识别的产品说明.这些相机描述文件(camera ...
- 【BZOJ 1005】[HNOI2008]明明的烦恼(暴力化简法)
[题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1005 [题意] 中文题 [题解] 一棵节点上标有序号的树会和一个prufer数列唯一对 ...
- 【BZOJ 1660】 [Usaco2006 Nov]Bad Hair Day 乱发节
1660: [Usaco2006 Nov]Bad Hair Day 乱发节 Time Limit: 2 Sec Memory Limit: 64 MB Submit: 678 Solved: 32 ...
- Can not Stop-Computer in powershell 6.0
1 PS C:\Program Files\PowerShell\6.0.0-beta.6> Stop-ComputerStop-Computer : Failed to stop the co ...
- 远程登录工具 —— filezilla(FTP vs. SFTP)、xshell、secureCRT
filezilla:是一个免费开源的 FTP 软件,分为客户端版本和服务器版本,具备所有的 FTP 软件功能. 支持的协议:FTP & SFTP(Secure File Transfer Pr ...
- Kali linux 2016.2(Rolling)中metasploit的搜集特定地址的邮件地址
不多说,直接上干货! 使用search_email_collector搜集特定地址的邮件地址 search_email_collector 要求提供一个邮箱后缀,通过多个搜索引擎的查询结果分析使用此后 ...
- ajax中Post和Get请求方式的区别?
ajax中Post和Get请求方式的区别: 1.Post传输数据时,不需要在URL中显示出来,而Get方法要在URL中显示. 2.Post传输的数据量大,可以达到2M,而Get方法由于受到URL长度的 ...
- CUDA笔记(十)
下午仔细研究了两个程序,然后搜了一下解决方法 http://blog.sina.com.cn/s/blog_6de28fbd01011cru.html http://blog.csdn.net/che ...
- 用jquery控制表格奇偶行及活动行颜色
虽然jquery流行已经很多年了,一直都感觉很难,也没有花时间去学习它,只是偶尔哪天心血来潮了去看一点点,时隔多日又会忘得一干二净.最近用到表格奇偶行不同色,不得不去再看jquery,虽然感觉还是难, ...
- UI Framework-1: Native Controls
Native Controls Background Despite the fact that views provides facilities for custom layout, render ...