#P10865. [HBCPC2024] Genshin Impact Startup Forbidden III
[HBCPC2024] Genshin Impact Startup Forbidden III
题目描述
Blue-edged Shot is forbidden from playing Genshin Impact by LeavingZ. However, today LeavingZ went to Huazhong University of Science and Technology, School of Cyber Science and Engineering, to harvest the gold medal of the 2024 International Collegiate Programming Contest in Hubei Province, China.
An activity of Genshin Impact called Dodoco's Bomb-Tastic Adventure
has begun. This is a single-player game, where each game involves a pond. The pond can be divided into an by grid, with the cell in the -th row and -th column represented by . Among these, cells contain fish, and you will play as the Spark Knight Klee, who fishes with explosives.
If Klee drops a bomb at , all the cells satisfying will be covered by the explosion. For every cell covered by the explosion, Klee will catch one fish from it. Klee can drop bombs at any location. The question is, to catch all the fish, how many Jumpy Dumpty
bombs are needed at a minimum?
输入格式
The first line contains three integers () --- the size of the grid and the number of cells containing fish.
The following lines, each line contains three integers (), representing there are fish in cell .
It is guaranteed that the input cell are unique.
输出格式
Output a single integer, denoting the minimum number of bombs needed.
5 5 3
1 1 2
2 2 1
5 5 2
4
提示
One possible way is to drop two bombs at and another two at .
It can be proven that there is no solution with a smaller answer.