傻叉了一晚上,把t打成x,然后这题神奇在于输出一段数,不足的不用输出,一开始我的是直接找没有后面就退,然后这样会格式错误囧……然后最后zj的还卡了下空间,于是不用string就过了……string毁一生……

const
maxn=;
mm=;
var
hash,size,left,right,fix,value,time,num,shi,cost:array[..maxn]of longint;
who:array[..maxn,..]of longint;
trie:array[..maxn,'A'..'Z']of longint;
n,tot,total,peo,u,i,j,k,ii,t:longint;
s:string;
ch:char; procedure lt(var t:longint);
var
k:longint;
begin
k:=right[t];
right[t]:=left[k];
left[k]:=t;
size[k]:=size[t];
size[t]:=size[left[t]]+size[right[t]]+;
t:=k;
end; procedure rt(var t:longint);
var
k:longint;
begin
k:=left[t];
left[t]:=right[k];
right[k]:=t;
size[k]:=size[t];
size[t]:=size[left[t]]+size[right[t]]+;
t:=k;
end; procedure insert(var t:longint;y,z,l:longint);
begin
if t= then begin
inc(total);
t:=total;
value[t]:=y;
fix[t]:=random(mm);
time[t]:=z;
hash[t]:=l;
left[t]:=;
right[t]:=;
size[t]:=;
exit;
end;
inc(size[t]);
if y<=value[t] then begin
insert(right[t],y,z,l);
if fix[right[t]]<fix[t] then lt(t);
end
else begin
insert(left[t],y,z,l);
if fix[left[t]]<fix[t] then rt(t);
end;
end; procedure delete(var t:longint;y,z:longint);
begin
if t= then exit;
dec(size[t]);
if (value[t]=y) and (time[t]=z) then begin
if left[t]= then t:=right[t]
else
if right[t]= then t:=left[t]
else
if fix[right[t]]<fix[left[t]] then begin
lt(t);
delete(left[t],y,z);
end
else begin
rt(t);
delete(right[t],y,z);
end;
exit;
end;
if (y>value[t]) or (y=value[t]) and (z<time[t])
then delete(left[t],y,z)
else delete(right[t],y,z);
end; function rank(t,y,z:longint):longint;
begin
if t= then exit();
if (y=value[t]) and (z=time[t]) then exit(size[left[t]]+);
if (y>value[t]) or (y=value[t]) and (z<time[t]) then exit(rank(left[t],y,z));
exit(size[left[t]]++rank(right[t],y,z));
end; procedure outs(x:longint);
var
i:longint;
begin
for i:= to who[x][] do
write(chr(who[x][i]));
end; procedure find(t,x:longint;var y:longint);
begin
if (t=) or (y=) then exit;
if x<=size[left[t]] then begin
find(left[t],x,y);
if y> then begin
dec(y);
if y= then begin
outs(hash[t]);
writeln;
exit;
end;
outs(hash[t]);
write(' ');
find(right[t],,y);
end;
end
else begin
if x=size[left[t]]+ then begin
dec(y);
if y= then begin
outs(hash[t]);
writeln;
exit;
end;
outs(hash[t]);
write(' ');
inc(x);
end;
find(right[t],x-size[left[t]]-,y);
end;
end; begin
readln(n);
randomize;
peo:=;
total:=;
tot:=;
for ii:= to n do begin
read(ch);
if ch='+' then begin
u:=;
s:='';
read(ch);
repeat
s:=s+ch;
if trie[u][ch]= then begin
inc(tot);
trie[u][ch]:=tot;
end;
u:=trie[u][ch];
read(ch);
until ch=' ';
readln(j);
if num[u]= then begin
inc(peo);
num[u]:=peo;
cost[peo]:=j;
shi[peo]:=ii;
who[peo][]:=length(s);
for i:= to who[peo][] do who[peo][i]:=ord(s[i]);
insert(t,j,ii,peo);
end
else begin
delete(t,cost[num[u]],shi[num[u]]);
cost[num[u]]:=j;
shi[num[u]]:=ii;
insert(t,j,ii,num[u]);
end;
end
else
if ch='?' then begin
readln(s);
if (ord(s[])>=) and (ord(s[])<=) then begin
u:=;
for i:= to length(s) do u:=trie[u][s[i]];
writeln(rank(t,cost[num[u]],shi[num[u]]));
end
else begin
val(s,i);
j:=;
if i+j>peo then j:=peo-i+;
find(t,i,j);
end;
end;
end;
end.

bzoj 1862: [Zjoi2006]GameZ游戏排名系统 & bzoj 1056: [HAOI2008]排名系统的更多相关文章

  1. BZOJ 1862: [Zjoi2006]GameZ游戏排名系统 [treap hash]

    1862: [Zjoi2006]GameZ游戏排名系统 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1318  Solved: 498[Submit][ ...

  2. bzoj 1056 [HAOI2008]排名系统(1862 [Zjoi2006]GameZ游戏排名系统)

    1056: [HAOI2008]排名系统 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1854  Solved: 502[Submit][Statu ...

  3. 【BZOJ】1862: [Zjoi2006]GameZ游戏排名系统 & 1056: [HAOI2008]排名系统(treap+非常小心)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1862 http://www.lydsy.com/JudgeOnline/problem.php?id ...

  4. 1056/1862. [ZJOI2006]GameZ游戏排名系统【平衡树-splay】

    Description GameZ为他们最新推出的游戏开通了一个网站.世界各地的玩家都可以将自己的游戏得分上传到网站上.这样就可以看到自己在世界上的排名.得分越高,排名就越靠前.当两个玩家的名次相同时 ...

  5. bzoj1056: [HAOI2008]排名系统 && 1862: [Zjoi2006]GameZ游戏排名系统

    hash 加上 平衡树(名次树). 这道题麻烦的地方就在于输入的是一个名字,所以需要hash. 这个hash用的是向后探查避免冲突,如果用类似前向星的方式避免冲突,比较难写,容易挂掉,但也速度快些. ...

  6. bzoj1056/1862 [Zjoi2006]GameZ游戏排名系统

    题目链接:1,2 treap恶心题,不多说 #include<algorithm> #include<iostream> #include<cstdlib> #in ...

  7. BZOJ_1862_[Zjoi2006]GameZ游戏排名系统&&BZOJ_1056_[HAOI2008]排名系统_Splay

    BZOJ_1862_[Zjoi2006]GameZ游戏排名系统&&BZOJ_1056_[HAOI2008]排名系统_Splay Description 排名系统通常要应付三种请求:上传 ...

  8. [HAOI2008]排名系统& [Zjoi2006]GameZ游戏排名系统

    1056: [HAOI2008]排名系统 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2487  Solved: 711[Submit][Statu ...

  9. [洛谷P2584][ZJOI2006]GameZ游戏排名系统

    题目大意:同[洛谷P4291][HAOI2008]排名系统(双倍经验) 题解:略 卡点:无 C++ Code: #include <cstdio> #include <map> ...

随机推荐

  1. python的阶段复习

    1.ABCD乘于9 = DCBA,求ABCD的值,且ABCD均互不相等 #!/usr/bin/env python # -*- coding:utf-8 -*- # @Time :2017/12/26 ...

  2. 获取附加在方法上的Attribute

    如下: class Program { static void Main(string[] args) { var methodInfo = typeof(Program).GetMethod(&qu ...

  3. hdu1069Monkey and Banana(动态规划)

    Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  4. 移动性能测试之gemebench安装

    越来越多的人从事各种移动端性能测试,但工具和文档的资料却相对较少,这两天需要测试一款APP的性能,就来先简单介绍下gamebench的安装吧! 作为国人来说,使用gamebench还是有相当多的坑点: ...

  5. 第五篇 Flask组件之SQLAchemy及Flask-SQLAlchemy插件/Flask-Script/Flask-migrate/pipreqs模块

    SQLAlchemy组件 一. 介绍 SQLAlchemy是一个基于Python实现的ORM框架.该框架建立在 DB API之上,使用关系对象映射进行数据库操作,简言之便是:将类和对象转换成SQL,然 ...

  6. JVM常见配置

    堆设置 -Xms:初始堆大小 -Xmx:最大堆大小 -XX:NewSize=n:设置年轻代大小 -XX:NewRatio=n:设置年轻代和年老代的比值.如:为3,表示年轻代与年老代比值为1:3,年轻代 ...

  7. Python基础 之 文件操作

    文件操作 一.路径 文件绝对路径:d:\python.txt 文件相对路径:在IDEA左边的文件夹中 二.编码方式 utf-8 gbk... 三.操作方式 1.只读 r 和 rb 绝对路径的打开操作 ...

  8. Python 学习笔记之——用 sklearn 对数据进行预处理

    1. 标准化 标准化是为了让数据服从一个零均值和单位方差的标准正态分布.也即针对一个均值为 \(mean\) 标准差为 \(std\) 的向量 \(X\) 中的每个值 \(x\),有 \(x_{sca ...

  9. Fluent Python: @property

    Fluent Python 9.6节讲到hashable Class, 为了使Vector2d类可散列,有以下条件: (1)实现__hash__方法 (2)实现__eq__方法 (3)让Vector2 ...

  10. es6从零学习(二):promise

    es6从零学习(二):promise 一:promise的由来 某些情况下,回调嵌套很多时,代码就会非常繁琐,会给我们的编程带来很多的麻烦,这种情况俗称——回调地狱.由此,Promise的概念就由社区 ...