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

18069번 - Cross-Stitch 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB21141365.000%

문제

Cross-stitch is a form of needlework known since prehistoric times. A cross-stitch pattern consists of several crosses on the face of the fabric, that are connected on the backside. Traditionally, the whole pattern should be embroidered by one thread.

Carol is going to mass-produce cross-stitch patterns. Each pattern will be accompanied by the rectangular patch of fabric and the thread that is required to embroider this pattern. Carol wants to minimize the length of the thread that is required for the pattern.

You are given the face of the pattern. You should design the backside, so that the total length of the thread is minimal. The crosses on the pattern’s face are 8-connected, i.e. it is possible to reach each cross from any other by a sequence of chess king’s moves.

입력

The first line of the input contains two integers w and h — the width and the height of the patch of fabric (1 ≤ w, h ≤ 100).

The following h lines contain the face of the pattern. Each of them contains w characters, where ‘X’ represents a cross, and ‘.’ — an empty space. The face of the pattern contains at least one cross and crosses are 8-connected.

출력

The first line of output should contain the single integer n — the number of stitches required to embroider the pattern.

The following n + 1 lines should contain the coordinates of the points where a needle comes from the backside to the face or back: xi, yi for i = 0..n. The upper-left corner of the patch has coordinates (0, 0), and the bottom-right one — (w, h). The first stitch goes to the face of the pattern, the second one — to the backside, the third one — to the face, and so on. It is possible to duplicate stitches at the backside, but not at the face. None of the stitches should have zero length.

제한

예제 입력 1

3 2
.XX
..X

예제 출력 1

11
1 1
2 0
2 1
3 0
2 0
3 1
2 1
3 2
2 2
3 1
2 1
1 0

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2019-2020 North-Western Russia Regional Contest C번

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

출처

대학교 대회

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

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