IOI '00 - Beijing, China
A parking center by the Great Wall has a long row of parking places. One
end of the row is considered left and the other end is considered right.
The row is full of cars. Each car has a type and several cars may be of
the same type. The types are identified by integer values. A number of
workers decide to order the cars parked in the row in ascending order
from left to right by the car types using the following method. In what
is called a round, each of the workers can simultaneously drive one car
out of its place and then park it in a place from where a car has been
moved out in the same round. It may be that some workers are not moving
a car in a round. For efficiency, a small number of rounds is
preferable.
Suppose that
is the number of cars and
is the number of workers.
You are to write a program which, given the types of the parked cars and
the number of workers, finds such a way to sort the cars that the number
of rounds needed is at most
, that is,
rounded
up. The minimal number of rounds is never greater than
.
Consider the following example. There are
parked cars of types
,
,
,
and
with
workers. The initial placement of the cars from left to
right identified by their types is 2 3 3 4 4 2 1 1 3 1
.
The minimal number of rounds is three, and the rounds can be implemented
so that the placement after each round is as follows:
2 1 1 4 4 2 3 3 3 1
– after round
,
2 1 1 2 4 3 3 3 4 1
– after round
, and
1 1 1 2 2 3 3 3 4 4
– after round
.
Input Specification
The first line contains three integers. The first integer is the number
of cars
. The second integer is the number of
types
. The car types are identified by the
integers from
to
. There is at least one car of each type. The
third integer is the number of workers
. The second
line contains
integers, where the
-th integer is the
type of the
-th car in the row, starting from the left end
of the row.
Output Specification
The first line should contain one integer
, which is the number of
rounds in the solution. The next
lines each describe one round, in
order from
to
. In each line, the first integer is the number of
cars
, which are moved in that round. After that follow
integers, identifying car positions. The car positions are identified by
the integers from
to
starting from the left end. The first two are
a pair describing how one of the cars is moved: the first integer is the
position from the left end before the round and the second is the
position from the left after the round. The next two lines are a pair
describing how another car is moved, and so on. There may be several
different solutions for these
lines, and your program only needs to
output one of them.
Sample Input
Copy
10 4 4
2 3 3 4 4 2 1 1 3 1
Sample Output
Copy
3
4 2 7 3 8 7 2 8 3
3 4 9 9 6 6 4
3 1 5 5 10 10 1
Scoring
Suppose that your program's output for an evaluation run is
and
is
. If in your program's output the
rounds are
not described correctly or they do not produce the desired order for the
cars, then your score is
. Otherwise, your score will be calculated
from the maximum score as follows:
 |
score |
 |
score |
 |
score |
 |
score |
Comments