Logo
(追記) (追記ここまで)

21240번 - Cyclically Shifted Maze 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB142225.000%

문제

Let's call a maze a rectangular field of cells, where cells can either be empty or contain a wall, and one can move from an empty cell to its empty neighbour cells in four directions.

Let's call a maze connected if it's possible to reach any its empty cell from any other empty cell by moving in four directions.

There was a connected maze of size $n \times m$. It was cyclically shifted some rows down and some columns right, but nobody knows the exact shifts. Find all possible shifts.

입력

The first line contains two integers $n$ and $m$ (1ドル \le n, m \le 200$) --- the sizes of maze.

Each of the next $n$ lines contains $m$ characters "." or "#" --- empty cells and walls, correspondingly.

There is at least one empty cell in the maze.

출력

In the first line output a single integer $k$ (0ドル \le k \le n \cdot m$) --- the number of possible shifts.

In each of the next $k$ lines output two integers $r_i$ and $c_i$ (0ドル \le r_i < n, 0 \le c_i < m$) --- the number of rows the original maze was shifted down and the number of columns it was shifted right. Pairs ($r_i,ドル $c_i$) should be output in lexicographical order. Original maze must be connected for each of these cases.

제한

예제 입력 1

5 6
..####
.###..
...#.#
##...#
.###..

예제 출력 1

9
0 2
0 3
0 4
1 2
1 3
1 4
4 2
4 3
4 4

예제 입력 2

8 10
##########
..........
#.####..##
..###..##.
#....##...
######..##
....###...
....###...

예제 출력 2

2
0 5
1 5

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 8: Grand Prix of Samara C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /