Hide

# Minesweeper Squared During a game of Minesweeper you have arrived in the situation shown in the image, with an $n\times n$ square surrounded by $1$s, themselves surrounded by unknown cells. Your task is to determine which of the $4n+4$ surrounding $1$-cells is guaranteed to not contain a mine.

If you are unfamiliar with the rules of Minesweeper, here is a description:

1. Each of the red-labelled cells is either empty or contains a mine. All other cells are empty.

2. Each cell with a blue $1$ is adjacent to exactly one mine. Two cells are said to be adjacent if they share an edge or a corner. Thus, except at the border, every cell is adjacent to $8$ other cells.

Determine which of the red-labelled cells are safe, i.e., guaranteed to not contain a mine.

## Input

An integer $n$ with $1 \leq n \leq 1\, 000$, the side length of the square. The image corresponds to $n = 6$.

It can be shown that there exists at least one valid placement of mines for each $n$.

## Output

First print the number $m$ of safe cells. Then print a line with $m$ integers, the indices of the safe cells in increasing order. The cells are indexed clockwise from $1$ to $4n+4$, starting at the bottom left corner, as shown in the image.

Sample Input 1 Sample Output 1
3

8
1 3 5 7 9 11 13 15

Sample Input 2 Sample Output 2
1

0


CPU Time limit 1 second
Memory limit 1024 MB
Statistics Show
{"ft_lang_label":"__label__en","ft_lang_prob":0.8756099,"math_prob":0.98734796,"size":1035,"snap":"2022-27-2022-33","text_gpt3_token_len":291,"char_repetition_ratio":0.12124151,"word_repetition_ratio":0.0,"special_character_ratio":0.28405797,"punctuation_ratio":0.11111111,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97367615,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-25T10:16:12Z\",\"WARC-Record-ID\":\"<urn:uuid:2dd71e4c-d25b-4051-9edd-c0ad83e00ba7>\",\"Content-Length\":\"24563\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:67986853-4f68-427c-ad6a-3816c43e2bb8>\",\"WARC-Concurrent-To\":\"<urn:uuid:9d4ca614-ddb9-4956-8ce9-2a1aedf93225>\",\"WARC-IP-Address\":\"104.26.10.67\",\"WARC-Target-URI\":\"https://open.kattis.com/problems/minrojikvadrat\",\"WARC-Payload-Digest\":\"sha1:K54PU57SWR2WHJP2W3MKHA6OW7WW7R2K\",\"WARC-Block-Digest\":\"sha1:EFW4DHWMEIYZW5JNMAM5LBQA2XXYKBRK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103034930.3_warc_CC-MAIN-20220625095705-20220625125705-00764.warc.gz\"}"}