Crazy Forks

면접 대비

시간 제한1초메모리 제한2048 MB

요약
잘린 ASCII 이미지로 포크를 읽어 손잡이의 행 개수와 각 갈래의 길이를 왼쪽부터 순서대로 출력한다.
난이도

보통10점 중 4점

유형
구현, 시뮬레이션, 배열, 문자열
정답자
아직 제출이 없습니다

문제

John runs a shop selling antique silverware. He recently got some great publicity, and now lots of people are bringing in old collections of spoons, knives, and forks. He wants to sort the forks by size, shape, and type, but there are simply too many of them. John decides to use a camera and a computer program to label the forks automatically, but he isn't much of a programmer. John needs your crazy image-processing skills.

You helped Jon set up a camera which is reliably snapping a 50×5050 \times 50 black-and-white image of each fork. But John needs numerical measurements. Write some code to read in each image, and output the lengths of the handle and each of the tines.

입력

Every input is an image of some fork, drawn out with spaces (" ") as white pixels and hashes ("#") as black pixels.

Each line of the input is a mix of ss (0≤s≤500 \leq s \leq 50) white pixels and hh (1≤h≤501 \leq h \leq 50) black pixels. These lines are the rows of our image.

Note: The lines may each be less than 5050 characters long, since extra spaces at the end of the line have all been removed. There may also be fewer than 5050 lines of input, since empty rows have all been removed.

Every input starts with pp (1≤p≤481 \leq p \leq 48) rows showing the handle of the fork. This handle section has 00 or more white columns and then a black column.

After the end of the handle section, there is a single row of ww (3≤w≤503 \leq w \leq 50) black pixels, with no white pixels between them.

The remaining rr (1≤r≤481 \leq r \leq 48) rows show the tines of the fork. There are tt (2≤t<w2 \leq t < w) tines, each a column of back pixels separated by columns of white pixels. The left-most column will always be a tine. Likewise, the rightmost tine aligns with the right side of the horizontal line above.

출력

The output consists of two lines. The first line prints the length in rows, pp, of the handle.

The second line is a space delineated list of tt numbers, each in the range 1≤x≤r1 \leq x \leq r. Each number is the length of a tine in rows, with the numbers ordered left-to-right according to the tines' positions in the input.

예제2

  1. 예제 1

    입력
      #
      #
      #
    ######
    #  # #
    #  # #
    #  #
       #
    
    예상 출력
    3
    3 4 2
    
  2. 예제 2

    입력
           #
           #
           #
           #
    ##########
    #  #  #  #
    #  #  #
    
    예상 출력
    4
    2 2 2 1