| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 4 | 2 | 2 | 100.000% |
Emperor Kostas is planning to commemorate the victory against his rival Max by building an Arc of Triumph. He has already designed the Arc and is now looking for an engineer who would build it as cheap as possible.
An arc is a narrow structure made out of stone blocks. It is fully described by its twodimensional cross-section. For example, the cross-section of one of the arc of triumphs in Rome is as follows:
######## ######## ######## ###..### #.#..#.# #.#..#.#
In this cross-section # denotes a block and . denotes an empty space.
In order for an arc to stand, all of the blocks have to be stable. A block is stable if:
For example, in the following diagram:
######## ######## ##XAYZ## ###..### B.#..#.# C.#..#.#
the bloc B is stable because it is standing on a stable block C (the latter is stable since it is standing on the ground). The block A is stable because it belongs to an interval XAYZ where the outer blocks X and Z are stable.
An arc is built by putting one block after another. At any moment of construction all of the blocks have to be stable. For this reason, it is impossible to build some of the arcs without additional temporary constructions. For example, it is not possible to build an arc depicted above because it will never be possible to put block A in a stable manner. Therefore, the engineer is going to use a temporary wooden construction. The wooden construction is made out of wooden blocks.
While building them it is important to take into account the same requirements: blocks are put one by one and at any moment of building the blocks have to be stable. When determining the stability of the block both wooden and stone blocks are considered identical.
Therefore, the arc depicted above can be built using three wooden blocks. The essential step is illustrated here:
..####.. ###^.### #.#^.#.# #.#^.#.#
(^ denotes wooden blocks).
The construction starts with a plain empty field and continues with performing consecutive steps. Possible types of steps are listed below:
At each moment of time all of the blocks that are put up have to be stable. Wodden blocks are expensive and Kostas is willing to buy as few wooden blocks as possible. The removed wooden blocks may be used again.
Your task is to build an arc using the smallest possible amount of wooden blocks. After the construction has ended, the stone blocks have to be in exactly the same positions as it is stated in the plan. However, there may be some wooden blocks remaining.
In the first line four numbers separated by spaces are presented: arc width M, arc heigth N, and parameters A and B that describe the scoring function (see section Grading).
In the following N lines the arc is described (starting from the top and ending at the bottom) – each of them contains M symbols # and . (# denotes a block and . denotes an empty space).
Output the whole arc construction process: for each step output a line with two numbers separated by spaces – the coordinates of the block you wish to add or remove. If there have not yet been a block in that place, a block will be put there:
If a wooden block has already been there, it will be removed.
This problem has ten tests worth 10 points each.
You will be awarded full 10 points if you build the arc having used no more than A wooden blocks. If you use more than B blocks, or provide a baddly formatted result file, or the arc collapses, or it is not fully constructed, then you will be awarded 0 points. If you build the arc having used x wooden blocks (A ≤ x ≤ B), you will be awarded 2 + 8 × ((B−x)/(B−A))2 points.
4 6 2 5 .#.. ###. #.#. #### #..# #..#
0 0 3 0 0 1 3 1 0 2 3 2 1 0 1 1 1 2 2 2 1 1 1 0 0 3 2 3 0 4 2 4 1 4 1 5
.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... #... #..# .... .... #... #..# #..# #..# #... #..# #..# #..# #..# #..# ---------------------------------- .... .... .... .... .... .... .... #... #... #... #... #... #... #... #... #... #... #... #..# #..# #..# #..# #.## #### #..# #..# #..# #.^# #.^# #.^# #..# #..# #.^# #.^# #.^# #.^# ---------------------------------- .... .... .... .... .... .#.. #... #... #... #.#. ###. ###. #... #... #.#. #.#. #.#. #.#. #### #### #### #### #### #### #..# #..# #..# #..# #..# #..# #.^# #..# #..# #..# #..# #..#
Olympiad > Lithuanian Olympiad in Informatics > Lithuanian Olympiad in Informatics 2016/2017 > National Round (2) > 10-12 Classes ?-2번