2017ecjtu-summer training #4 UESTC 1584
此题链接 http://acm.uestc.edu.cn/#/problem/show/1584
此题和hdu1541几乎完全一样,我们要先对坐标排序,再进行操作。
hdu1541题解 http://www.cnblogs.com/stranger-/p/7157899.html
AC代码
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100010
using namespace std;
int c[maxn*];
int k[maxn];
struct node
{
int x,y;
}point[maxn];
bool cmp(const node &a,const node &b)
{
if(a.y==b.y)
return a.x<b.x;
return a.y<b.y;
}
int lowbit(int x)
{
return x&(-x);
}
int getsum(int x)
{
int ans=;
while(x>)
{
ans+=c[x];
x-=lowbit(x);
}
return ans;
}
void add(int x,int y)
{
while(x<maxn)
{
c[x]+=y;
x+=lowbit(x);
}
}
int main()
{
int n;
int x,y;
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%d%d",&point[i].x,&point[i].y);
}
sort(point,point+n,cmp);
for(int i=;i<n;i++)
{
k[getsum(point[i].x)]++;
add(point[i].x,);
}
for(int i=;i<n;i++)
printf("%d\n",k[i]);
return ;
}
2017ecjtu-summer training #4 UESTC 1584的更多相关文章
- UESTC 1584 Washi与Sonochi的约定【树状数组裸题+排序】
题目链接:UESTC 1584 Washi与Sonochi的约定 题意:在二维平面上,某个点的ranked被定义为x坐标不大于其x坐标,且y坐标不大于其y坐标的怪物的数量.(不含其自身),要求输出n行 ...
- UESTC 1584
http://acm.uestc.edu.cn/#/problem/show/1584 Washi与Sonochi的约定 Time Limit: 3000/1000MS (Java/Others) ...
- 2017ecjtu-summer training #4 UESTC 1599
题目链接 http://acm.uestc.edu.cn/#/problem/show/1599 题意 n个数 每次合并最小的两个数加到sum中,直到只剩一个数为止 常规解会超时,后来想到了用 ...
- 2017ecjtu-summer training #4 UESTC 30
最短路 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) 在每年的校赛里,所有进入 ...
- 2015 UESTC Winter Training #10【Northeastern Europe 2009】
2015 UESTC Winter Training #10 Northeastern Europe 2009 最近集训都不在状态啊,嘛,上午一直在练车,比赛时也是刚吃过午饭,状态不好也难免,下次比赛 ...
- 2015 UESTC Winter Training #8【The 2011 Rocky Mountain Regional Contest】
2015 UESTC Winter Training #8 The 2011 Rocky Mountain Regional Contest Regionals 2011 >> North ...
- 2015 UESTC Winter Training #7【2010-2011 Petrozavodsk Winter Training Camp, Saratov State U Contest】
2015 UESTC Winter Training #7 2010-2011 Petrozavodsk Winter Training Camp, Saratov State U Contest 据 ...
- 2015 UESTC Winter Training #6【Regionals 2010 >> North America - Rocky Mountain】
2015 UESTC Winter Training #6 Regionals 2010 >> North America - Rocky Mountain A - Parenthesis ...
- 2015 UESTC Winter Training #4【Regionals 2008 :: Asia - Tehran】
2015 UESTC Winter Training #4 Regionals 2008 :: Asia - Tehran 比赛开始时电脑死活也连不上WIFI,导致花了近1个小时才解决_(:зゝ∠)_ ...
随机推荐
- 506. Relative Ranks
Given scores of N athletes, find their relative ranks and the people with the top three highest scor ...
- 【转载】Python中的正则表达式教程
本文http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html 正则表达式经常被用到,而自己总是记不全,转载一份完整的以备不时之需. 1. ...
- Sum of odd and even elements
Given an integer N, you have to print the sum of odd numbers and even numbers form 1 to N Input:Firs ...
- bzoj 1179: [Apio2009]Atm
Description Input 第 一行包含两个整数N.M.N表示路口的个数,M表示道路条数.接下来M行,每行两个整数,这两个整数都在1到N之间,第i+1行的两个整数表示第i条道路 的起点和终点的 ...
- application19事件 20多少步骤 具体20多少只有微软知道!!!
- 关于asp.net web form 和 asp.net mvc 的区别
asp.net web forms 有什么缺陷? 1.视图状态臃肿:服务器和客户端传输过程中包含了大量的试图状态——在现在的web程序中甚至多达几百kb,而且每次往返都会请求,导致服务器请求带宽增加, ...
- 面向对象 初级版 (Preview) 未完
概述: 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数里,日后使用无需重复编写,直接调用韩顺即可. 面向对象: 对函数进行分类和封装,让开发'更快更强' 面向对象和面向过程的通 ...
- 扎实基础之从零开始-Nginx集群分布式.NET应用
1 扎实基础之快速学习Nginx Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.其特点是占有内存少 ...
- Android studio打开项目一直卡住
修改/gradle/wrapper/gradle-wrapper.properties文件中的最后一行distributionUrl=:(可找一个可用项目的复制过来)
- HTML 中有用的字符实体
HTML 中有用的字符实体