原题:
Bomb Game
1000ms 65536K
描述:
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
注释:
Source: Croatia OI 2002 National – Juniors
译文:
炸弹游戏
1000ms 65536K
描述:
Bosko和Susko在一块有A行B列格子的矩形棋盘上玩一个有趣的游戏。
当游戏开始时,Susko将他的一个碉堡放置在棋盘的一个格子上,紧接着Bosko在棋盘上选择一个格子放置他的炸弹,每放置一个炸弹,Susko就会告诉Bosko,他的碉堡是否在炸弹的爆炸范围内。
炸弹的爆炸范围是一个中心坐标为(R,S),直径为P(P总为奇数)的正方形区域,炸弹位于坐标(R,S)。正方形区域的边和棋盘的格线平行,长度为P。
在Bosko把所有的炸弹放完后,需要找到Susko碉堡的位置。需要注意的是,碉堡的位置可能不唯一,你需要做的是编写一个程序来帮助Bosko确定所有可能的碉堡的总数。
输入:
第一行输入三个整数A、B和K,1 <= A、B、C <=100。A代表棋盘的行数,B代表棋盘的列数,K代表炸弹的总数。
接下来的K行都包含四个整数R、S、P和T用来描述炸弹投放的位置是第R行第S列以及正方形爆炸范围的边长P,1 <= R <= A, 1 <= S <= B, 1 <= P <= 99,P是一个奇数,如果 爆炸范围内有碉堡,则T = 1,否则T = 0。
输出:
输出一个整数,表示所有可能的Susko的碉堡的总数。
样例输入:
5 5 3 3 3 3 1 3 4 1 0 3 4 3 1
样例输出:
5
注释:
Source: Croatia OI 2002 National – Juniors