1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
var
f: text;
n, i: int16;
a, b: array of int32;
procedure swp(var x, y: int32);
var
tmp: int32;
begin
tmp := x;
x := y;
y := tmp
end;
procedure qsort(l, h: int16);
var
i, j: int16;
tmp: int32;
begin
i := l;
j := h;
tmp := a[(l + h) div 2];
repeat
while a[i] < tmp do
inc(i);
while a[j] > tmp do
dec(j);
if i <= j then
begin
swp(a[i], a[j]);
swp(b[i], b[j]);
inc(i);
dec(j)
end;
until i > j;
if l < j then
qsort(l, j);
if i < h then
qsort(i, h)
end;
begin
assign(f, 'CLB.IN');
reset(f);
readln(f, n);
setlength(a, n);
setlength(b, n);
for i := 0 to n - 1 do
readln(f, a[i], b[i]);
close(f);
qsort(0, n - 1);
for i := 0 to n - 1 do
writeln(a[i], ' ', b[i])
end.
|