HDU4585 Shaolin (STL和treap)】的更多相关文章

Shaolin HDU - 4585       Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The master of Shaolin evaluates a young man mainly by his talent on understanding the Buddism s…
1208: [HNOI2004]宠物收养所 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 5956  Solved: 2317[Submit][Status][Discuss] Description 最 近,阿Q开了一间宠物收养所.收养所提供两种服务:收养被主人遗弃的宠物和让新的主人领养这些宠物.每个领养者都希望领养到自己满意的宠物,阿Q根据领养 者的要求通过他自己发明的一个特殊的公式,得出该领养者希望领养的宠物的特点值a(a是一个正整数,a<…
传送门:动态序列操作 在一个动态变化的序列中,完成以下基本操作: (1)插入一个整数 (2)删除一个整数 (3)查找序列中最大的数 (4)查找序列中最小的数 (5)求x的前驱(前驱定义为不大于x的序列中最大的数) (6)求x的后继(后继定义为不小于x的序列中最小的数) 输入 第一行为n,表示操作的次数,接下来有n行(n≤100000) 每行为以下操作之一: (1)1 x:将x插入 (2)2 x:删除x,x在序列中一定存在,若有多个相同值,只删除一个. (3)3:查找序列中最大的数 (4)4:查找…
Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The master of Shaolin evaluates a young man mainly by his talent on understanding the Buddism script…
Problem 问你一个数的前驱和后继 Solution Treap模板题 Notice 注意输出那个人的编号 Code #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define sqz main #define ll l…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4585 题意大意:很多人想进少林寺,少林寺最开始只有一个和尚,每个人有有一个武力值,若这个人想进少林,必须和比他先进去的人比武并且武力值最接近他的比武,如果有相同的则选择武力值比他小的,问当他进去的时候要和哪个和尚比武. 思路:正常情况暴力,n=100000,呵呵. n*n的操作肯定不行的,最少要优化到nlogn,联想到map,map里的数会自动排序,它是由红黑树实现的,能实现O(n)的排序(对第一关…
没想到map还有排序功能,默认按照键值从小到大排序 #include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <map> #include <algorithm> #include <cstdlib> using namespace std; int main() { int n; int id,g; while(s…
Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The mast…
Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 64    Accepted Submission(s): 38 Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin t…
平衡树·Treap 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho:小Hi,我发现我们以前讲过的两个数据结构特别相似. 小Hi:你说的是哪两个啊? 小Ho:就是二叉排序树和堆啊,你看这两种数据结构都是构造了一个二叉树,一个节点有一个父亲和两个儿子. 如果用1..n的数组来存储的话,对于二叉树上的一个编号为k的节点,其父亲节点刚好是k/2.并且它的两个儿子节点分别为k*2和k*2+1,计算起来非常方便呢. 小Hi:没错,但是小Hi你知道有一种办法可以把堆和二叉…