| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 1 | 0 | 0 | 0.000% |
As usual, Lora is spending her time at work playing video games. Today we’re going to look at a variation of the game Bomberman.
The game consists of a grid of size 109 x109. Each cell can either be empty, contain a box, or contain a rock. There are N boxes and M rocks in the grid. The player has an unlimited amount of bombs of the following two types:
The player detonates the bombs one by one, i.e. a given bomb explodes before the next one is placed. It is guaranteed that a cell containing a box is not on the edge of the grid and the 4 cells that border it are all empty. The goal of the game is to destroy all boxes with a minimum possible number of bombs. Help Lora by writing a program bombs that given a playing field finds the minimal number of bombs needed to destroy all boxes, as well as the positions they should be placed in.
The first line of the standard input contains the number of boxes N. Each of the following N lines contains two integers in the range [1;109] – the row and column of each box respectively. The next line contains the number of rocks M. Each of the following M lines contains the row and column of each rock, again integers in the range [1;109]. The upper left corner of the table is on the first row and on the first column.
On the first line of the standard output print a single integer K - the minimal number of bombs needed to destroy all boxes. On each of the following K lines print 3 integers h x y, interpreted as follows:
The cell in which a bomb is placed should be empty at the moment the bomb is being placed. If there is more than one solution using a minimum number of bombs, print any of them. You should output the lines in the order of the placement of the bombs.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 8 | N, M ≤ 10 |
| 2 | 10 | N, M ≤ 2∙103, There are at most two boxes in a single row or a single column. |
| 3 | 18 | N, M ≤ 2∙103, Only rows 2 and 4 contain non-empty cells |
| 4 | 26 | N, M ≤ 2∙103 |
| 5 | 38 | N, M ≤ 4∙105 |
8 6 2 11 4 2 9 6 7 4 9 6 4 6 9 11 9 2 11 7 8 9
5 1 6 5 1 6 4 0 3 9 1 11 5 1 11 10
The bombs have the following effects:
Any correct solution using 5 bombs will be accepted.