You want to make your Christmas table special and that's why you've gotten into
a plantation of faryuks, which is the only one in the world. You want to take
home some of this mysterious fruit. However, it's not that easy to steal
faryuks. The plantation is surrounded by a high fence, and the only way to get
in or out is through the checkpoint. You can bring as many faryuks as you want
to the plantation, but it is strictly forbidden to take them out. This fruit
has a very strong aroma, and the automatic aroma sensor at the checkpoint will
raise an alarm if the aroma of faryuks is detected. Fortunately, you know that
there is an error in the aroma-detecting software. Because of the use of
one-byte variables, it does not raise an alarm if the total aroma strength of
all the faryuks being taken out is an integer divisible by 256.
You have a bottle of scent and a can of deodorant with you. When a faryuk is
sprayed upon with the deodorant, its aroma strength decreases by 25 percent.
When a faryuk is scented, its aroma strength increases by 10 percent. (In both
cases, the aroma strength can become fractional). The amount of each of the
substances you have is enough for treating only one faryuk. A faryuk can be
treated first with one substance and then with the other. The effects of the
deodorant and of the scent are short. After you take a faryuk through the
checkpoint, its aroma strength restores to the initial value.
You've come to the plantation empty-handed and you want to take out the n
faryuks you like most of all. Will you be able to do that?
Input
The first line contains the number n of faryuks you want to take out
(1 ≤ n ≤ 12). The second line contains n integers in
the range from 1 to 1000, which are their aroma strengths.
Output
If it is impossible to take out from the plantation all the faryuks
that you want, output “IMPOSSIBLE”.
Otherwise, output in the first line the number of actions necessary for
carrying out your plan. Then output the sequence of actions, one action per
line. If you want to take out from the plantation k > 0 faryuks with the
numbers a1, …, ak, output the line “take k a1 a2 … ak
”.
Similarly, if you want to return to the plantation s > 0 faryuks with the
numbers b1, …, bs, output the line “return s b1 b2 … bs
”.
If you want to spray the deodorant on the faryuk with the number p, output the line
“dearomatize p
”. If you want to scent the faryuk with the number q,
output the line “aromatize q
”. The faryuks are numbered from 1 to n in
the order in which they are given in the input.
The number of actions in the sequence can't exceed 20000. If there are
several ways to take out all the faryuks, output any of them such that the number
of exiting the checkpoint with faryuks is minimal.
Samples
input | output |
---|
3
36 56 200
| 4
take 2 2 3
return 1 3
aromatize 3
take 2 1 3
|
1
100
| IMPOSSIBLE
|
Problem Author: Alex Samsonov
Problem Source: XIV Open USU Championship