62 - ZOJ Monthly, January 2008 - 1009
Have you ever played the flash game "10 drops" before?
I have tried this game several times, but I am not good at playing this game because of my bad imagination. So I come to you, one of the best programmers in the world, for help. The target is to find the status of the grid after several given actions. Do you think that is too easy? But, to me, it is an impossible mission. So, if you help me to solve it, I'll appreciate it.
There are multiple test cases. Each case begins with a line containing four integer n, m, k, p where n < 20 indicates the size of the grid is n * n; m <= 1000 is the number of rest drops in your tank; k <= 10 is the burst size of blob; and p is the number of actions. The next n lines each with n integers less than k. And then p lines each with 2 integers x, y stand for an action. Both x and y are less than n.
Process to the end of file.
Print the number of left drops after p actions in tank in a line. Then print the description of the grid after p actions as the input shows.
Print a blank line between cases.
6 10 5 3
Author: WU, Zejun