# Untitled

unknown
pascal
3 years ago
2.0 kB
10
Indexable
Never
```type mang=array[1..1000005] of longint;
var f1,f2:text;
n,k,i,j,x,c,ans:longint;
a:array[1..1000005] of longint;  //Danh sach ke
cs:array[0..100000] of longint;
check:array[0..100000] of boolean;
kq:array[1..1000005] of longint;
procedure sort(var a:mang; left,right:longint) ;
var i,j,k,t:longint;
begin
i:=left;
j:=right;
k:=a[(i+j) div 2];
while (i<j) do
begin
while (a[i]<k) do inc(i);
while a[j]>k do dec(j);
if (i<=j) then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
inc(i);
dec(j);
end;
end;
if (left<j) then sort(a,left,j);
if (i<right) then  sort(a,i,right);
end;
procedure Enter;
begin
assign(f1,'t.inp');
reset(f1);
for i:=1 to n do
begin
cs[i]:=cs[i-1]+x;
for j:=1 to x do
begin
inc(c);
end;
end;
close(f1);
end;
procedure Solve;
begin
check[k]:=true;
ans:=1;
kq[1]:=k;
i:=1;
while (i<=ans) do
begin
for j:=cs[kq[i]-1]+1 to cs[kq[i]] do
begin
if check[a[j]]=false then
begin
inc(ans);
kq[ans]:=a[j];
check[a[j]]:=true;
end;
end;
inc(i);
end;
end;
procedure Result;
begin
assign(f2,'t.out');
rewrite(f2);
writeln(f2,ans);
sort(kq,1,ans);
for i:=1 to ans do write(f2,kq[i],' ');
close(f2);
end;

begin
Enter;
Solve;
Result;
end.

```