描述:
Bosko and Susko are playing an interesting game on a board made of rectangular fields arranged in A rows and B columns.
When the game starts, Susko puts its virtual pillbox in one field one the board. Then Bosko selects fields on which he will throw his virtual bombs. After each bomb, Susko will tell Bosko whether his pillbox is in the range of this bomb or not.
The range of a bomb with diameter P (P is always odd), which is thrown in field (R, S), is a square area. The center of the square is in the field (R, S), and the side of the square is parallel to the sides of the board and with length P.
After some bombs have been thrown, Bosko should find out the position of Susko's pillbox. However, the position may be not unique, and your job is to help Bosko to calculate the number of possible positions.
输入:
First line of input contains three integers: A, B and K, 1 <= A, B, K <=100. A represents the number of rows, B the number of columns and K the number of thrown bombs.
Each of the next K lines contains integers R, S, P and T, describing a bomb thrown in the field at R-th row and S-th column with diameter P, 1 <= R <= A, 1 <= S <= B, 1 <= P <= 99, P is odd. If the pillbox is in the range of this bomb, T equals to 1; otherwise it is 0.
输出:
Output the number of possible fields, which Susko's pillbox may stay in.
样例输入:
5 5 3
3 3 3 1
3 4 1 0
3 4 3 1
样例输出:
5
翻译:
爆炸游戏
Bosko和 Susko正在由A行B列的方块的木板上玩一个有趣的游戏。
当游戏开始,Susko会确切地把它的小屋放在木板上的一块地上。然后Bosko会选择一块它能够放置炸弹的地方。在每次放置之后Susko将会告诉Bosko是否他的小屋里有炸弹。
炸弹按直径P排列(P是额外的),炸弹被放在以R S为长和宽的方框里。方框的中间,和方框的边上都被用木板隔开了。
在一些炸弹被扔下之后,Bosko应该找到Susko的直径的位置。然而,这个位置可能不是唯一的,并且你的工作就是去帮助Bosko计算可能的位置的数量。
输入:
第一行输入包含三个整数A B 和K,1<=A,B,K<=100。A代表了一行数字的数目,B代表一列数字的数目并且K代表被扔炸弹的数目。
每下一个K行包含R S P T,描述的分别是一个直径为P的炸弹被扔在第R行第S列。1<=R<=A,1<=S<=B,1<=P<=99.P是额外的,如果小屋在炸弹的排列中,T等于1,否则T等于0
输出:
输出可能的小屋方块的数目
样例输入:
5 5 3
3 3 3 1
3 4 1 0
3 4 3 1
样例输出:
5