hdu 5204 Rikka with sequence 智商不够系列
Rikka with sequence
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5204
Description
现在有一个序列,因为这个序列很任性,开始时空的。接下来发生了n个事件,每一个事件是以下两种之一:
1.勇太利用黑炎龙的力量在序列的开头、结尾以及每相邻两个元素之间都插入一个权值为w的元素。若第一步执行事件一,执行后数列仅有一个数字w.
2.勇太想要六花告诉他第L个元素到第R个中权值第k小的权值是多少。
当然,这个问题对于萌萌哒六花来说实在是太难了,你可以帮帮她吗?
Input
第一行一个正整数n。接下来n行每一行描述了一种操作:
1.如果输入格式是1 w,表示第一种事件。
2.如果输入格式是2 L R k,表示第二种事件。
1≤n≤105,1≤L≤R≤1018,1≤w≤109,保证L,R,k合法, R不会超过当前序列长度。
Output
Sample Input
1 3
1 1
2 2 3 2
1 2
2 3 5 2
2 1 4 4
Sample Output
2
3
HINT
题意
题解:
每一次加入数的时候,都会加入在奇数位置,我们每次/2之后, 就相当于在回到了上一个状态
然后搞呀搞就好啦
正如题解所讲:大水题(雾
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/* int buf[10];
inline void write(int i) {
int p = 0;if(i == 0) p++;
else while(i) {buf[p++] = i % 10;i /= 10;}
for(int j = p-1; j >=0; j--) putchar('0' + buf[j]);
printf("\n");
}
*/
//**************************************************************************************
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} struct node
{
ll x,num;
};
bool cmp(node a,node b)
{
return a.x<b.x;
}
ll a[maxn];
node b[maxn];
int main()
{
int n=read(),tot=;
for(int i=;i<n;i++)
{
int t=read();
if(t==)
a[++tot]=read();
else
{
ll l,r,org;
scanf("%lld%lld%lld",&l,&r,&org);
int num=;
for(int i=tot;i>=;i--)
{
b[++num].x=a[i];
b[num].num=(r+)/-l/;
r/=;
l=(l+)/;
if(r<l)
break;
}
sort(b+,b+num+,cmp);
for(int i=;i<=num;i++)
{
org-=b[i].num;
if(org<=)
{
printf("%lld\n",b[i].x);
break;
}
}
}
}
}
hdu 5204 Rikka with sequence 智商不够系列的更多相关文章
- 判断相同区间(lazy) 多校8 HDU 5828 Rikka with Sequence
// 判断相同区间(lazy) 多校8 HDU 5828 Rikka with Sequence // 题意:三种操作,1增加值,2开根,3求和 // 思路:这题与HDU 4027 和HDU 5634 ...
- HDU 5828 Rikka with Sequence (线段树)
Rikka with Sequence 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5828 Description As we know, Rik ...
- hdu 5828 Rikka with Sequence 线段树
Rikka with Sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5828 Description As we know, Rik ...
- HDU 5828 Rikka with Sequence(线段树 开根号)
Rikka with Sequence Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- HDU 5828 Rikka with Sequence (线段树+剪枝优化)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5828 给你n个数,三种操作.操作1是将l到r之间的数都加上x:操作2是将l到r之间的数都开方:操作3是 ...
- HDU 5828 Rikka with Sequence(线段树)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5828 [题目大意] 给出一个数列,要求支持区间加法,区间开方和区间和查询操作. [题解] 考虑开方 ...
- HDU 5828 Rikka with Sequence(线段树区间加开根求和)
Problem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he g ...
- HDU 5828 Rikka with Sequence
好久没写线段树了,这题作为一个回味.. 第一种操作的话,就是一个延迟标记. 第二种操作可以暴力更新下去,但是有一个优化,如果某区间内所有值都是一样的,或者最大值和最小值相差1,那么到此结束,不要继续往 ...
- HDU - 6087 Rikka with Sequence (可持久化treap+倍增+重构)
题目链接 感谢Dream_Lolita的题解,经过无数次失败的尝试之后终于AC了... 线段树是维护区间信息的强大工具,但它的形态是固定的,只支持修改和删除操作,不支持插入.反转.复制.分裂合并等操作 ...
随机推荐
- es6新语法Object.assign()
1.介绍 Object.assign用于对象的合并,将源对象的所有可枚举属性复制到目标对象,只拷贝源对象自身的属性继承属性补考呗 Object.assign(target,source1,...)第一 ...
- 消息队列ActiveMQ的使用详解
通过上一篇文章 <消息队列深入解析>,我们已经消息队列是什么.使用消息队列的好处以及常见消息队列的简单介绍. 这一篇文章,主要带大家详细了解一下消息队列ActiveMQ的使用. 学习消息队 ...
- discuz 积分按日重新计算,(摒弃以前24小时计算)
修改\source\module\forum\forum_misc.php将 foreach(C::t('forum_ratelog')->fetch_all_sum_score($_G['ui ...
- linux的curl用法【转】
每分钟访问云签到任务执行页面.顺便记录了下curl的用法.以下内容摘自阮一峰博客. 一.查看网页源码 直接在curl命令后加上网址,就可以看到网页源码.我们以网址www.sina.com为例(选择该网 ...
- java中String的==和equals的区别
首先看代码1: public static void main(String[] args) { List<String> list=new ArrayList<String> ...
- CentOS7安装Hadoop2.7完整步骤
总体思路,准备主从服务器,配置主服务器可以无密码SSH登录从服务器,解压安装JDK,解压安装Hadoop,配置hdfs.mapreduce等主从关系. 1.环境,3台CentOS7,64位,Hadoo ...
- gc 调优记录
qps 10,0000 -Xms10240m -Xmx10240m -XX:NewRatio=5 -XX:SurvivorRatio=6 2017-12-19T15:10:14.539+0800: 1 ...
- centos使用boost过程
1. 安装gcc,g++,make等开发环境 yum groupinstall "Development Tools" 2. 安装boost yum install boost ...
- 解决 VUE 微信 IOS 路由跳转问题
watch: { "$route"(){ if (/iPhone|mac|iPod|iPad/i.test(navigator.userAgent)) { location.hre ...
- Codeforces Round #492 (Div. 2) [Thanks, uDebug!]
这次的题好奇怪哦... C - Tesla 思路:先把跟停车位相邻的车停进去,然后开始转圈... #include<bits/stdc++.h> #define LL long long ...