#P2805. [NOI2009] 植物大战僵尸
[NOI2009] 植物大战僵尸
Description
We will consider the scenario where Zombies attack Plants in the game. Note that the rules in this problem differ from the actual game. There are two roles, Plants and Zombies. Each Plant has a set of attack positions, and it can protect those positions. A Zombie attacks a plant by stepping onto the plant’s position and eating it.
The map is modeled as an -by- grid. Rows are numbered from top to bottom as to , and columns are numbered from left to right as to . There is a placed at every position on the map. For simplicity, we denote the plant at row and column as .
There are many types of Plants, such as “attack-type,” “defense-type,” and “economy-type.” To describe each Plant, define and as follows:
-
— the energy a Zombie gains by destroying plant .
If is a non-negative integer, then destroying grants energy . If it is negative, then destroying costs energy . -
— the set of positions that plant can attack.
Zombies must enter from the right side of the map and can only move horizontally. The only way a Zombie attacks a plant is by moving to that plant’s position and eating it. Therefore, a Zombie attack on row always starts from the right side of the map. That is, for an attack on row , the Zombies must first attack . If they want to attack with , they must first destroy and move to position to attack.
In this problem, Plants have infinite attack power. Once a Zombie enters any plant’s attack position, that Zombie is instantly eliminated and has no time to perform any attack action. Therefore, even if a Zombie steps onto a plant’s position, if that position is in another plant’s attack set, the Zombie is instantly eliminated and the plant at that position remains unharmed. (In our setting, a plant’s attack set does not include its own position; otherwise you could never destroy it.)
The Zombies’ goal is to attack the Plants’ formation to obtain the maximum energy income. Each time, you may choose one attackable plant to attack. The objective is to design an attack plan for the Zombies, choosing which plants to attack and in what order, to maximize the total energy income.
Input Format
The first line contains two positive integers and , the number of rows and columns of the map.
The next lines describe the plant at each position. For and , the -th of these lines gives the information for plant in the following format:
The first integer is , the second integer is , the number of positions in , followed by positions , indicating that can attack the position at row and column .
Output Format
Output a single integer: the maximum energy income that can be obtained. Note that you may also choose to make no attacks, in which case the income is .
3 2
10 0
20 0
-10 0
-5 1 0 0
100 1 2 1
100 0
25
Hint
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , .
Notes
Statement modified by @syksykCCC.
Translated by ChatGPT 5
京公网安备 11011102002149号