UFO Rectangles
면접 대비시간 제한2초메모리 제한512 MB
평평해진 칸으로 이루어진 격자가 서로 겹치지 않는 직사각형 테두리들의 합집합임이 보장될 때, 각 테두리를 모두 찾아 네 모서리 좌표를 출력한다.
문제
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 , where and are both at least . 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 and (), the dimensions of the photo.
Then follow lines defining the photo. Each of them consists of 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 (), the number of flattened rectangles the photo contains.
In each of the following lines, output four integers , , , and (, ) 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 to from top to bottom, the columns are numbered with integers from to from left to right.
You may output rectangles in any order. If there are several possible answers, output any one of them.