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

17658번 - Chess 스페셜 저지다국어

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

문제

You are given a chess table NxM (N rows and М columns) and some of the cells are inaccessible. Rows are numbered from top to bottom from 0 and columns are numbered from left to right from 0. This way the top left cell has coordinates (0,0). On this table there is a chess knight, which can make at most K jumps. It cannot be in a cell which is inaccessible. Jump means a valid move of a chess knight on the table (shown on the picture).

Your task is to destroy the knight. For the task you have an artillery weapon, which can with one shot hit any cell you desire. If in the moment the shot is fired, the knight is in the cell fired upon, then the knight is destroyed. After the shot the cell remains as it was before – accessible or inaccessible. The knight can make 0 or 1 jumps between two shots of your weapon. You never know where the knight is.

Write a program, which calculates the minimal number of shots with which one can be certain that the knight is destroyed and finds one such list of shots.

입력

On the first line of the standard input are 3 integers separated with a space - N, M and K.

On each of the next N lines there are M symbols describing the table, where ‘.’ - describes an accessible cell and ‘#’ - describes an inaccessible cell.

출력

On the first line of the standard output print a single integer – the minimal found number of shots, required to be sure that the knight is destroyed.

On each of the following lines (as many as the found minimal number) output two non-negative integers seperated with a space – the coordinates of the current struck cell. The coordinates of the hit cells should be printed in the order they are shot at.

If there is more than one solution print any of them.

제한

  • 1 ≤ N,М,К ≤ 100

예제 입력 1

3 5 1
.....
#####
.#.#.

예제 출력 1

10
0 0
0 1
0 2
0 3
0 4
2 0
2 2
2 4
0 1
0 3

In this example the knight can make at most one jump. With the first 5 shots it is guaranteed that the knight will be destroyed if it was on the top row and did not jump to the bottom row. With the next 3 shots it is guaranteed that the knight will be destroyed if it was on the top row and jumped to the bottom row during the first 5 shots or if the knight was initially on the bottom row and did not jump. With the last 2 shots we guarantee that the knight will be destroyed if it was initially on the bottom row and during the past 3 shots has jumped to the top row.

예제 입력 2

3 3 1
...
...
...

예제 출력 2

13
0 0
1 0
2 0
2 1
2 2
1 2
0 2
0 1
1 1
2 1
2 0
1 0
0 0

힌트

출처

Olympiad > International Autumn Tournament in Informatics > 2018 > Group A (Seniors) 6번

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

출처

대학교 대회

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

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