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

15113번 - Grid Coloring 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB184676352.500%

문제

You have an m-by-n grid of squares that you wish to color. You may color each square either red or blue, subject to the following constraints:

  • Every square must be colored.
  • Colors of some squares are already decided (red or blue), and cannot be changed.
  • For each blue square, all squares in the rectangle from the top left of the grid to that square must also be blue.

Given these constraints, how many distinct colorings of the grid are there? The grid cannot be rotated.

입력

The first line of input consists of two space-separated integers m and n (1 ≤ m, n ≤ 30).

Each of the next m lines contains n characters, representing the grid. Character ‘B’ indicates squares that are already colored blue. Similarly, ‘R’ indicates red squares. Character ‘.’ indicates squares that are not colored yet.

출력

Print, on a single line, the number of distinct colorings possible.

제한

예제 입력 1

3 2
..
B.
.R

예제 출력 1

6

예제 입력 2

7 6
......
.....B
.B..R.
......
...B..
.R....
...R..

예제 출력 2

3

예제 입력 3

2 2
R.
.B

예제 출력 3

0

힌트

For the first sample, the 6 ways are:

BB BB BR BR BB BB
BB BR BR BR BR BB
BR BR BR RR RR RR

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2017 Pacific Northwest Region Programming Contest > Division 1 J번

ICPC > Regionals > North America > Pacific Northwest Regional > 2017 Pacific Northwest Region Programming Contest > Division 2 W번

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

출처

대학교 대회

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

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