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

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

Letters Q and F

면접 대비

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

요약
겹치지 않게 Q와 F 모양을 그려 만든 격자가 주어질 때, 그려진 Q와 F의 개수를 각각 센다.
난이도

보통10점 중 5점

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

문제

Little Lev is learning how to draw letters Q and F. Initially, he has a white grid of size n×mn \times m. Then he will draw several letters of one of the following two shapes:

Lev will not rotate or mirror these two shapes. Every time he draws a new letter, he will choose a position for the letter inside the grid and paint all cells of the shape black. Lev will only draw letters in such a way that before drawing all black cells of the letter are white --- that is, he will never paint a cell twice.

You are given the final coloring of the grid. Count the number of letters Q and letters F drawn by Lev.

입력

The first line contains two integers nn and mm --- the height and the width of the grid (5≤n≤3005 \le n \le 300; 3≤m≤3003 \le m \le 300).

The next nn lines contain mm characters each, denoting the final state of the grid. A white cell is denoted by '.', a black cell is denoted by '\#'.

It is guaranteed that the grid is a valid result of Lev's drawing.

출력

Print two integers --- the number of letters Q and the number of letters F drawn by Lev, respectively.

힌트

Illustration for the fourth example test:

예제4

  1. 예제 1

    입력
    5 3
    ###
    #.#
    ###
    ..#
    ..#
    
    예상 출력
    1 0
    
  2. 예제 2

    입력
    5 3
    ###
    #..
    ##.
    #..
    #..
    
    예상 출력
    0 1
    
  3. 예제 3

    입력
    5 8
    ###..###
    #.#..#..
    ###..##.
    ..#..#..
    ..#..#..
    
    예상 출력
    1 1
    
  4. 예제 4

    입력
    8 8
    .....###
    ###..#.#
    #.######
    ###.####
    #.###.##
    #.#.###.
    ..#...#.
    ......#.
    
    예상 출력
    2 2