#P3274. [SCOI2011] 植物大战僵尸
[SCOI2011] 植物大战僵尸
Description
Walnut Bowling is a minigame in Plants vs. Zombies. Now Crazy Dave only gave lxhgww some ordinary walnuts and asked lxhgww to throw them like bowling balls to smash the zombies in the yard.
The yard consists of lanes, numbered from to from top to bottom. Each lane is divided into cells. There are zombies in total, each standing in some cell, and you may assume their positions are fixed.
The game has rounds. In each round, you can choose one lane and throw a walnut. The thrown walnut first rolls straight from left to right along that lane. After it hits the first zombie, it begins to roll along a -degree diagonal toward the center line of the yard (that is, in the first lanes it rolls down-right, and in the last lanes it rolls up-right; it is guaranteed that is even). The yard is bounded by walls. When a diagonally moving walnut hits a wall or a zombie, it bounces: up-right becomes down-right, or vice versa. The round ends when the walnut can no longer hit any zombie.
Note: Multiple zombies may stand in the same cell; in that case, each time the walnut only kills one zombie in that cell. To kill as many zombies as possible, at the start of each round lxhgww chooses the lane whose resulting path will kill the maximum number of zombies under the current state. When there is a tie, he chooses the lane with the smallest index.
To evaluate this strategy, lxhgww needs your help to compute the number of zombies that can be killed by this method.
Input Format
The first line contains three integers , , . Then each of the next lines contains two integers , , meaning that the -th zombie is at lane , column (the -th cell from the left).
Output Format
Output lines. The first lines each contain two integers , meaning that in the -th round, the walnut is thrown from lane and hits zombies during its movement. The last line contains a single integer: the total number of zombies hit.
4 2 1
1 2
5 2
2 2
2
Hint
Constraints
For of the testdata, it is guaranteed that: , , , .
For of the testdata, it is guaranteed that: , , , .
For of the testdata, it is guaranteed that: , , , .
For all testdata, it is guaranteed that: .
Translated by ChatGPT 5
京公网安备 11011102002149号