poj 1442 Black Box
来源:互联网 发布:mac os 10.8无法升级 编辑:程序博客网 时间:2024/05/10 08:22
http://poj.org/problem?id=1442
题目又臭又长就不贴了,给两串数a[i],u[i]长度分别为M,N(我读入的时候是N,M。习惯了。。。)。对于每个u[i],输出a数组前u[i]个中从小到大的第i个数。
//================================================================================================
其实这道题可以用大根堆+小根堆做的,但是为了练手就用Treap硬搞掉了。。。
大根堆+小根堆的做法就是保证大根堆的大小为i,每次加入新数先入大根堆,弹出堆顶的数,把这个数放入小根堆,询问的时候就是大根堆堆顶的数,处理下一个u[i+1]的时候从小根堆弹出堆顶的数加入大根堆。
就是弹来弹去的。。。YY下就出来了。。。不过我还没有实现,如果有错求指教、、
Treap这个就不用说了吧,都是Treap的基本操作:加入一个数。询问k大的数。
一开始在询问k大值调用函数find的时候当过程用了。。。值没有传上去。。。
竟然浪费了时间去调这种错误、、、不可饶恕啊!!!
ACCODE
program pku_1442;
const maxn=99999999;
var val,a,fix,sum,left,right:array[0..30000] of longint;
//============================================================================
procedure right_rotate(var k:longint);
var t:longint;
begin
end;
//============================================================================
procedure left_rotate(var k:longint);
var t:longint;
begin
end;
//============================================================================
procedure ins(var k:longint);
begin
end;
//============================================================================
function find(k:longint):longint;
begin
end;
//============================================================================
begin
end.
- poj 1442 Black Box
- poj 1442 Black Box
- POJ 2160 BOX
- poj 2488
- Box of Bricks
- POJ 2485 Highways
- POJ 3299
- poj 1905
- HDU 2088 Box of Bricks
- HDU 1326 Box of Bricks
- POJ 2247 Humble Numbers
- POJ 1753 Flip Game
- POJ 1182 食物链
- POJ 3185 The Water Bowls
- POj 2379 ACM Rank Table
- POJ 1018 Communication System
- POJ 1050 To the Max
- POj 1159 Palindrome (dp)
- poj 2778 DNA Sequence
- poj 1634 Prison rearrangement
- bzoj 1051 [HAOI2006]受欢迎的牛
- HTML5简明教程-1.1.2.HTML5Canvas参考手册 之 笔触strokeStyle
- poj 1848 Tree
- poj 1442 Black Box
- poj 2001 Shortest Prefixes
- poj 2131 Key Insertion
- bzoj 1208 [HNOI2004]宠物收养所
- bzoj 1597 [Usaco2008 Mar]土地购…
- noi 2008 假面舞会 (bzoj 1064)
- bzoj 1579 [Usaco2009 Feb]Revampi…
- bzoj 1150 [CTSC2007]数据备份Back…
- bzoj 1857 [Scoi2010]传送带