Star HDU1541
看到图和坐标就想到了用二维数组来写 但是连数组的开不下 写好了也爆内存
没看到题目是按照y坐标升序给的坐标
这样就可以忽略y坐标 进行一维的树状数组
#include<bits/stdc++.h>
using namespace std;
#define N 32050
int c[N];
int ans[N];
int lowbit(int i)
{
return i&-i;
}
void update(int x,int v)
{
for(int i=x;i<N;i+=lowbit(i))
c[i]+=v;
return ;
}
int sum(int x)
{
int ans=;
for(int i=x;i>;i-=lowbit(i))
ans+=c[i];
return ans;
}
int main()
{
int k;
while(scanf("%d",&k)==)
{
memset(c,,sizeof(c));
memset(ans,,sizeof(ans));
for(int i=;i<=k;i++)
{
int a,b;
scanf("%d%d",&a,&b);
a++;
ans[ sum(a) ]++;
update(a,);
}
for(int i=;i<k;i++)
printf("%d\n",ans[i]);
}
}
Star HDU1541的更多相关文章
- 【Star CCM+实例】开发一个简单的计算流程.md
流程开发在CAE过程中处于非常重要的地位. 主要的作用可能包括: 将一些经过验证的模型隐藏在流程中,提高仿真的可靠性 将流程封装成更友好的界面,降低软件的学习周期 流程开发实际上需要做非常多的工作,尤 ...
- github中的watch、star、fork的作用
[转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...
- [deviceone开发]-Star分享的几个示例
一.简介 这个是star早期分享的几个示例,都非常实用,包括弹出的菜单,模拟支付密码输入等.初学者推荐.也可以直接使用.二.效果图 三.相关下载 https://github.com/do-proje ...
- 时隔一年再读到the star
The Star Arthur C. Clarke It is three thousand light-years to the Vatican. Once, I believed that spa ...
- Github上的Watch和 Star的区别
Github 推出了新的 Notification 系统,更改了原有的 Watch 机制,为代码库增加了 Star 操作.Notification 将接收 Watching 代码库的动态,包括:* I ...
- 纯css3 Star
<style><!--* { box-sizing: border-box; padding: 0px; margin: 0px; } body, html { height: 10 ...
- Got the Best Employee of the year 2015 Star Award
Got "The Best Employee of the year 2015 Star Award" from the company, thanks to all that h ...
- star ccm+ 11.02安装
STAR CCM+是CD-Adapco公司的主打软件,其安装方式较为简单,这里以图文方式详细描述STAR CCM+11.02安装过程. 1 安装准备工作2 正式安装3 软件破解4 软件测试 1 安装准 ...
- System.Diagnostics.Process.Star的用法
System.Diagnostics.Process.Start(); 能做什么呢?它主要有以下几个功能: 1.打开某个链接网址(弹窗). 2.定位打开某个文件目录. 3.打开系统特殊文件夹,如“控制 ...
随机推荐
- 13. Spring Boot 拦截器
1.thymeleaf 页面修改后可能不会实时反馈到Web,做2步骤: 1)禁用掉tymleaf 缓存: spring.thymeleaf.cache=false 2)IDE编辑器:Ctrl + F ...
- Linux - 文件操作
touch file # 创建空白文件 rm -rf 目录名 # 不提示删除非空目录(-r:递归删除 -f强制) dos2unix # windows文本转linux文本 unix2dos # lin ...
- QToolButton按钮
继承 QAbstractButton QToolButton是与工具操作相关的按钮,通常和QToolBar搭配使用.QToolButton一般不用来显示文本,而显示图标QIcon 需要 from P ...
- 第17月第26天 setImageForState变形
1. 关于UIButton,既可以采用setBackgroundImage 来设置底部图片,同时也可以采用 setImage方法: 两者还是有一定区别的: 首先setBackgroundImage, ...
- sqlite limit offset
limit 0,20 表示从第1条开始取20条数据 limit 20 offset 2 表示从第2条开始取出20条数据
- Django学习手册 - ORM choice字段 如何在页面上显示值
在module操作过程中使用choice字段: 核心: obj.get_字段名_display 定义module 数据结构: class msg(models.Model): choice = ( ( ...
- 修改BlackLowKey皮肤样式,增加占屏比
页面定制CSS代码 #home { margin: 0 auto; width: 100%; } #sideBar { min-height: 200px; padding: 0 5px 0 5px; ...
- python将图片转换为Framebuffer裸数据格式(终端显示图片)【转】
转自:https://www.cnblogs.com/zqb-all/p/6107905.html 要在ubuntu终端显示图片或者在板子的LCD显示图片,Framebuffer是一个简单易用的接口, ...
- passwd: Have exhausted maximum number of retries for service【转】
使用命令passwd修改密码时,遇到如下问题: # echo 'utf8'|passwd zhangsan --stdin Changing password for user zhangsan. p ...
- ES系列二、CentOS7安装ES head6.3.1
1.Head插件简介 ElasticSearch-head是一个H5编写的ElasticSearch集群操作和管理工具,可以对集群进行傻瓜式操作. 显示集群的拓扑,并且能够执行索引和节点级别操作 搜索 ...