QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#17945. Chocolate Phantom Thief Coco (Sweet)

Statistics

Coco, having been deeply impressed by the mystery novel "Chocolate Phantom Thief Lena," decided to reenact a famous scene from the book. The specific procedure is as follows:

  • Step 1: Prepare an $N \times N$ square grid of chocolate. The chocolate can be broken off at any $1 \times 1$ unit, and some parts are already removed. At this point, there are at least $4$ unit chocolates remaining, and they must form a single piece. Two unit chocolates are connected if they are adjacent horizontally or vertically, and a set of connected unit chocolates is called a single piece.
  • Step 2: Eat one unit chocolate from this chocolate such that the following condition is met:
    • After removing this unit chocolate, the remaining chocolate still forms a single piece, but cutting between any two adjacent unit chocolates in the remaining piece would split it into $2$ pieces.
  • Step 3: Shout Lena's famous line: "I'll let you off this time, but next time, I will definitely break the chocolate into pieces."

Coco has prepared a chocolate that satisfies the conditions of Step 1, but is struggling to decide which unit chocolate to remove to satisfy the condition of Step 2. Help Coco.

The first line contains the size of the chocolate $N$. $(2 \le N \le 40)$

From the second line, the state of the chocolate is given over $N$ lines. Each line contains $N$ characters without spaces, representing whether there is a unit chocolate in each cell. Each character is either # or .. If the $c$-th character of the $r$-th line is #, it means there is a unit chocolate at row $r$, column $c$; if it is ., there is none. The top-left cell of the chocolate is row $1$, column $1$.

All inputs satisfy the conditions of Step 1.

The first line outputs the number of different unit chocolates that can be removed to satisfy the condition of Step 2.

From the next line, output the row and column numbers of such unit chocolates, one per line. Output them in ascending order of row numbers, and for the same row number, in ascending order of column numbers.

Examples

Input 1

3
###
#.#
###

Output 1

8
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 3

Input 2

3
##.
###
###

Output 2

1
2 2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.