2761: [JLOI2011]不重复数字(平衡树)
2761: [JLOI2011]不重复数字
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 2133 Solved: 825
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
11
1 2 18 3 3 19 2 3 6 5 4
6
1 2 3 4 5 6
Sample Output
1 2 3 4 5 6
HINT
对于30%的数据,1 <= N <= 100,给出的数不大于100,均为非负整数;
对于50%的数据,1 <= N <= 10000,给出的数不大于10000,均为非负整数;
对于100%的数据,1 <= N <= 50000,给出的数在32位有符号整数范围内。
提示:
由于数据量很大,使用C++的同学请使用scanf和printf来进行输入输出操作,以免浪费不必要的时间。
Source
/**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ var
i,j,k,l,m,n,head:longint;
a,b:array[..] of longint;
lef,rig,fix:array[..] of longint;
procedure rt(var x:longint);
var f,l:longint;
begin
if (x=) or (lef[x]=) then exit;
f:=x;l:=lef[x];
lef[f]:=rig[l];
rig[l]:=f;
x:=l;
end;
procedure lt(var x:longint);
var f,r:longint;
begin
if (x=) or (rig[x]=) then exit;
f:=x;r:=rig[x];
rig[f]:=lef[r];
lef[r]:=f;
x:=r;
end;
function ins(var x:longint;y:longint):boolean;
begin
ins:=true;
if x= then
begin
x:=y;
exit;
end;
if a[y]<a[x] then
begin
if lef[x]= then lef[x]:=y else ins:=ins(lef[x],y);
end
else if a[y]>a[x] then
begin
if rig[x]= then rig[x]:=y else ins:=ins(rig[x],y);
end
else exit(false);
end;
begin
readln(m);
randomize;
for l:= to m do
begin
readln(n);head:=;
for i:= to n do
begin
read(a[i]);
lef[i]:=;rig[i]:=;
fix[i]:=random(maxlongint);
end;
readln;k:=;
for i:= to n do
if ins(head,i) then
begin
inc(k);
b[k]:=a[i];
end;
for i:= to k do
if i<k then write(b[i],' ') else writeln(b[i]);
end;
readln;
end.
2761: [JLOI2011]不重复数字(平衡树)的更多相关文章
- BZOJ 2761: [JLOI2011]不重复数字 水题
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2100 Solved: 809 题目连接 http:// ...
- bzoj 2761 [JLOI2011]不重复数字(哈希表)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 3210 Solved: 1186[Submit][Sta ...
- 2761: [JLOI2011]不重复数字(哈希表)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1770 Solved: 675[Submit][Stat ...
- 【BZOJ】2761: [JLOI2011]不重复数字(set+巨水题+超坑题)
http://www.lydsy.com/JudgeOnline/problem.php?id=2761 太水了,不说了. 但是这格式错误我已经没话说了....行末不能有空格 #include < ...
- bzoj 2761: [JLOI2011]不重复数字 (map||Treap)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2761 思路: map标记 实现代码: #include<bits/stdc++.h&g ...
- BZOJ 2761: [JLOI2011]不重复数字 set
Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 ...
- BZOJ 2761: [JLOI2011]不重复数字 hash哈希
题目就不贴了 点我看题 题意:这题题意很简明,就是给一个序列,把序列里相同的删掉,然后输出,按原数列顺序. 思路:这题之前QZZ和ZN大神犇叫我去做,辣时还不会hash,就留着了.最近某夏令营学会了h ...
- bzoj 2761: [JLOI2011]不重复数字
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #d ...
- bzoj 2761: [JLOI2011]不重复数字【hash】
map会T,双hash会冲突--于是非酋写了个三hash #include<iostream> #include<cstdio> #include<cstring> ...
随机推荐
- Javascript数据类型共有六种
Javascript数据类型共有六种 /* var box; alert(typeof box); // box是Undefined类型,值是undefined,类型返回的字符串是undefined ...
- Windows Server 2008 R2防火墙出站规则
出战规则指Windows Server 2008 R2系统访问外部的某台计算机通信数据流. 配置防火墙阻止Windows Server 2008 R2系统通过IE软件访问外部的网站服务器,阻止Wind ...
- [源代码] SailingEase .NET Resources Tool (.NET 多语言资源编辑器)
我在2016年10月发过一篇博客,介绍了我写过的一个多语言资源文件编辑器,并且做为免费软件发布给了出来. 陆续收到了一些朋友的反馈,有朋友很热心提了很多建议和关心的话,还有朋友发红包过来,让我很感动. ...
- Mybatis拦截器实现分页
本文介绍使用Mybatis拦截器,实现分页:并且在dao层,直接返回自定义的分页对象. 最终dao层结果: public interface ModelMapper { Page<Model&g ...
- easyui datagrid的json格式
easyui datagrid的json格式: {"columns":[[{"field":"one","title": ...
- 安装Ubuntu时的硬盘分区
根目录 大小:60G~100G(用来安装程序) 新分区的类型:主分区 新分区的位置:空间起始位置 用于:EXT4日志文件系统 挂载点:"/" 大小:4G 新分区的类型:逻辑分区 新 ...
- MongoDB基础之十 shared分片
水平分片实例分布图: mongodb sharding 服务器架构 1. 添加mongdb两个shared实例 # mkdir -p /home/m17 //home/m18 /home/m20 ...
- docker - 容器里安装ssh
docker安装ssh 通过命令行安装 pull ubuntu镜像 docker pull ubuntu:latest 启动并进入bash docker run -it -d ubuntu:laste ...
- UI进阶 即时通讯之XMPP好友列表、添加好友、获取会话内容、简单聊天
这篇博客的代码是直接在上篇博客的基础上增加的,先给出部分代码,最后会给出能实现简单功能的完整代码. UI进阶 即时通讯之XMPP登录.注册 1.好友列表 初始化好友花名册 #pragma mark - ...
- 无限二等分[0,1]这个区间之后还剩下啥?what's left after dividing an unit interval [0,1] infinitely many times?
Dividing an unit interval \([0,1]\) into two equal subintervals by the midpoint \(\dfrac {0+1} {2}=\ ...