Official

C - Digital Graffiti Editorial by en_translator


We can see that a point (x,y)(x, y) is a vertex if and only if there are exactly one or three #’s in the four cells surrounding the point (Sx,y,Sx+1,y,Sx,y+1,Sx+1,y+1)(S_{x, y}, S_{x + 1, y}, S_{x, y + 1}, S_{x + 1, y + 1}).

Note:
If there are exactly 22 #’s around them, it is not possible that they are placed diagonally, since the shape does not have self-intersection. Therefore they are placed adjacently, thus the circumference of the polygon does not bend there, so it is not necessarily a vertex.

Since all the edge rows and columns consists of ., we only have to check for each 1x<H,1y<W1 \le x \lt H, 1 \le y \lt W, so we don’t really have to worry about referencing out of bounds of SS.

posted:
last update:



2025-04-11 (Fri)
07:53:26 +00:00