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> ...
随机推荐
- hadoop学习笔记--集群搭建
注:大家常说的ssh其实就是一个免密码访问的东西,为了简化操作的,不用每次访问其他节点重新输入密码.但是要想配置如下: .在每台机器上执行 ssh-keygen -t rsa,连敲三次回车键(即设置空 ...
- Ubuntu14.04 安装Oracle JDK
在Ubuntu 14.04 中安装 Oracle JDK6,7 或 8. 准备:添加add-apt-repository工具 #apt-get install python-software-prop ...
- WebForm 内置对象、数据增删改、状态保持
一.内置对象 1.Response对象:响应请求 Response.Write("<script>alert('添加成功!')</script>"); → ...
- 内功心法 -- java.util.ArrayList<E> (4)
写在前面的话:读书破万卷,编码如有神--------------------------------------------------------------------下文主要对java.util ...
- 源码(07) -- java.util.Iterator<E>
java.util.Iterator<E> 源码分析(JDK1.7) ----------------------------------------------------------- ...
- web前端 兼容性问题
1:position属性使用过多或使用位置不恰当引起滚动时页面错乱 浏览器环境:ie7 position:relative; 网页上最直接表现就是极具破坏性的滚动错位,问题产生来自ie7自身渲染解析出 ...
- GitLab Wiki 内容恢复版本管理
原来一直在网站上写Wiki文档, 最近手欠误删一篇文档, 想要恢复文档时才发现原来gitlab的Wiki是用git管理的从此再也不用为误删担心了 实现步骤: mac系统安装gollow brew in ...
- 怎么写jquery插件
1. 添加js文件到html文件中,放下面的两行到html文档底部,</body>之前. <script src="js/jquery-1.9.1.min.js" ...
- WDCP下安装PHPWind
创建整站跟新建站点的区别是创建整站会一并生成ftp跟mysql数据库 这边只要填写一个域名(如果你有域名就填写下域名 如果你没有域名 或者跟我一样到这步去申请域名的可以填写ECS公网ip否则无法访问新 ...
- kbhit()的三个测试
#include <stdio.h> #include<conio.h> #include<stdlib.h> int main() { ; system(&quo ...