아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

UFO Rectangles

면접 대비

시간 제한2초메모리 제한512 MB

요약
평평해진 칸으로 이루어진 격자가 서로 겹치지 않는 직사각형 테두리들의 합집합임이 보장될 때, 각 테두리를 모두 찾아 네 모서리 좌표를 출력한다.
난이도

보통10점 중 7점

유형
구현, 완전 탐색, 시뮬레이션, 행렬
정답자
아직 제출이 없습니다

문제

Yandex has a secret department which deals with special orders from the governments of different countries. Recently, they received a message from a small banana republic that suffers from the aliens invasion! 

All of you heard about crop circles: those are the strange circle formations that sometimes appear on potato or wheat fields and may or may not be left by UFOs. In case of the banana republic, everything is a bit different: the nasty aliens are leaving not crop circles, but rectangles consisting of flattened banana plants. Now they ask Yandex to help them investigate what were the aliens doing on Earth recently.

You have a satellite photo of a banana field that is divided into cells each of which is either intact or flattened. The best UFO researchers believe that aliens tend to draw the rectangles by flattening all cells belonging to a rectangular frame of cells of size r×cr \times c, where rr and cc are both at least 33. Those frames never share cells, and also, for some strange reason, no two frames are touching by two or more sides.

XXXXXXXXX       XXXXX....        XXXXXXXXXX
X.XXXXX.X       X...XXXX.        X..XXXXX.X
X.X...X.X       X...XX.X.        X..X...X.X
X.XXXXX.X       X...XX.X.        X..X...X.X
X.......X       X...XXXX.        X..XXXXX.X
XXXXXXXXX       XXXXX....        XXXXXXXXXX

   OK              OK              NOT OK

Help the Yandex secret department to distinguish all the rectangles that were created by aliens, and you may possibly save Earth from an alien invasion!

입력

The first line of the input contains two integers nn and mm (3≤n,m≤20003 \leq n, m \leq 2000), the dimensions of the photo.

Then follow nn lines defining the photo. Each of them consists of mm characters. Each character is either "." for intact cells, or "X" for flattened cells.

It is guaranteed that the given picture corresponds to some set of rectangles that satisfy the conditions above.

출력

On the first line, output an integer kk (k≥0k \geq 0), the number of flattened rectangles the photo contains.

In each of the following kk lines, output four integers r_1r\_1, c_1c\_1, r_2r\_2, and c_2c\_2 (1≤r_1<r_2≤n1 \leq r\_1 < r\_2 \leq n, 1≤c_1<c_2≤m1 \leq c\_1 < c\_2 \leq m) denoting the row numbers and column numbers of the top-left and bottom-right corners of the rectangle. The rows are numbered with integers from 11 to nn from top to bottom, the columns are numbered with integers from 11 to mm from left to right.

You may output rectangles in any order. If there are several possible answers, output any one of them.

예제3

  1. 예제 1

    입력
    3 3
    XXX
    X.X
    XXX
    
    예상 출력
    1
    1 1 3 3
    
  2. 예제 2

    입력
    6 7
    XXXXXXX
    X.XX..X
    XXXXXXX
    XXXXXXX
    X.XX..X
    XXXXXXX
    
    예상 출력
    4
    1 1 3 3
    1 4 3 7
    4 1 6 3
    4 4 6 7
    
  3. 예제 3

    입력
    10 10
    ..........
    XXXXXXXXXX
    X..XXXX..X
    X..X..X..X
    X..XXXX..X
    X...XXXX.X
    X...X..X.X
    X...X..X.X
    X...XXXX.X
    XXXXXXXXXX
    
    예상 출력
    3
    2 1 10 10
    3 4 5 7
    6 5 9 8