#P1789. 【Mc生存】插火把

【Mc生存】插火把

Description

One day, linyorson created an n×nn \times n square grid in Minecraft. He has mm torches and kk glowstones, placed at positions (x1,y1)(x_1, y_1) through (xm,ym)(x_m, y_m) and (o1,p1)(o_1, p_1) through (ok,pk)(o_k, p_k), respectively. Any cell that has no light and has nothing placed on it will spawn monsters. How many cells in this grid will spawn monsters?

Note: In this problem the illumination ranges of torches and glowstone are different from the original Minecraft. Please follow the description given here.

P.S. The illumination range of a torch is:

Dark Light Dark
Dark Light Light Light Dark
Light Torch Light
Dark Light Dark
Dark Dark

Glowstone:

Light
Light Light Light
Glowstone
Light

Input Format

There are m+k+1m + k + 1 lines in total.
The first line contains n,m,kn, m, k.
Lines 22 through m+1m + 1 give the positions of torches xi,yix_i, y_i.
Lines m+2m + 2 through m+k+1m + k + 1 give the positions of glowstones oi,pio_i, p_i.

Note: There may be no glowstone, but there is at least one torch.

Output Format

Output the number of cells that will spawn monsters.

5 1 0
3 3

12

Hint

Constraints: 1n1001 \le n \le 100, 1m+k251 \le m + k \le 25, 1m251 \le m \le 25, 0k50 \le k \le 5.

Translated by ChatGPT 5