Wrote it with Treap.

Source: Internet
Author: User

1  Programhehe;2 type3shu=Record4 L,r,w,h,y,s:longint;5  End;6 var7 N,i,j,k,t,ans,root,size:longint;8X:Array[0..100000] ofShu;9 Ten   procedureUpdate (a:longint); One   begin Ax[a].s:=x[x[a].l].s+x[x[a].r].s+X[A].W; -   End; -  the   procedureRturn (vara:longint); -   var - T:longint; -   begin +t:=X[A].L; -x[a].l:=X[T].R; +x[t].r:=A; Ax[t].s:=X[a].s; at Update (a); -a:=T; -   End; -  -   procedureLturn (vara:longint); -   var in T:longint; -   begin tot:=X[A].R; +x[a].r:=X[T].L; -x[t].l:=A; thex[t].s:=X[a].s; * Update (a); $a:=T;Panax Notoginseng   End; -  the   procedureInsertvara:longint;b:longint); +   begin A    ifA=0  Then the    begin + Inc (size); -a:=size; $x[a].s:=1; $x[a].w:=1; -x[a].h:=b; -x[a].y:=random (maxlongint); the exit; -    End;Wuyi Inc (X[A].S); the    ifX[a].h=b ThenInc (X[A].W) -    Else ifB>x[a].h Then Wu    begin - Insert (x[a].r,b); About     ifX[x[a].r].y<x[a].y ThenLturn (a); $    End -    Else -    begin - Insert (x[a].l,b); A     ifX[x[a].l].y<x[a].y ThenRturn (a); +    End; the   End; -  $   functionFind (A,b:longint): boolean; the   begin the    ifA=0  Thenexit (false); the    ifX[a].h=b Thenexit (true); the    ifB>x[a].h Thenexit (Find (X[A].R,B)); - exit (Find (X[A].L,B)); in   End; the  the begin About readln (t); the   fori:=1  toT Do the  begin the read (n); +root:=0; -size:=0; theFillchar (x,sizeof (x),0);Bayi    forj:=1  toN Do the   begin the read (k); -    if  notFind (Root,k) Then -    ifj=1  Thenwrite (k) the    ElseWrite' ', k); the Insert (root,k); the   End; the Writeln; -  End; the End.
View Code 2761: [JLOI2011] do not repeat digital time limit:10 Sec Memory limit:128 MB
submit:2336 solved:895
[Submit] [Status] [Discuss] Description gives the number of N, requires the repetition of the removal, only the first occurrence of the number. For example, the number given is 1 2 18 3 3 19 2 3 6 5 4, of which 2 and 3 have duplicates, the result of removal is 1 2 18 3 19 6 5 4. Input enters the first behavior positive integer t, which indicates that there is a T group of data. Next, each set of data consists of two rows, the first positive integer n, which indicates the number of N. The second behavior is to go to a heavy n positive integer. Output for each set of data, a single line, the number left after the deduplication, separated by a space between the numbers. Sample Input2
11
1 2 18 3 3 19 2 3 6 5 4
6
1 2 3 4 5 6
Sample OUTPUT1 2 18 3 19 6 5 4
1 2 3 4 5 6
HINT

For 30% of the data, 1 <= N <= 100, the number given is not greater than 100, are non-negative integers;


For 50% of the data, 1 <= N <= 10000, the number given is not greater than 10000, are non-negative integers;


For 100% of the data, 1 <= N <= 50000, given the number within the 32-bit signed integer range.


Tips :


Because of the large amount of data, students using C + + use scanf and printf for input and output operations to avoid wasting unnecessary time.


Source [Submit] [Status] [Discuss]

Wrote it with Treap.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.