比赛 暑假培训六 评测结果 AAAAAAAAAA
题目名称 明明的随机数 最终得分 100
用户昵称 辨机ZN 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-23 09:08:38
显示代码纯文本
program ex(f1,f2);
 type
  zn=array [1..101] of integer;
  ma=array [1..1001] of boolean;
 var
  a,b:zn; f1,f2:text;  flag:ma;
  i,j,k,n,m:integer;
 procedure paixu(left,right:integer);
  var x,y,l,r:integer;
   begin
    l:=left; r:=right; x:=a[(l+r) div 2];
    repeat
    while a[l]<x do inc(l);
    while a[r]>x do dec(r);
    if l<=r then
     begin
      y:=a[l];
      a[l]:=a[r];
      a[r]:=y;
      inc(l);
      dec(r);
     end;
    until l>r;
    if l<right then paixu(l,right);
    if r>left then paixu(left,r);
   end;
 begin
  assign(f1,'random.in'); reset(f1);
  assign(f2,'random.out'); rewrite(f2);
  readln(f1,n);
  for i:=1 to n do read(f1,a[i]);
  for i:=1 to n do b[i]:=0;
  for i:=1 to 1000 do flag[i]:=true;
  paixu(1,n);
  j:=0;
  for i:=1 to n do
    if flag[a[i]] then
     begin
      inc(j);
      b[j]:=a[i];
      flag[a[i]]:=false;
     end;
  writeln(f2,j);
  for i:=1 to j do write(f2,b[i],' ');
  close(f1);
  close(f2);
 end.