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

34602번 - Control Towers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB13111184.615%

문제

You are an architect tasked with designing the new airport in your city. After you have completed your design, you just realize you forgot to allocate spaces for the control towers.

The layout of the new airport can be represented by a 2D grid of $r$ rows and $c$ columns, with the rows numbered from 1ドル$ to $r$ (top to bottom) and the columns numbered from 1ドル$ to $c$ (left to right). The cell in row $i$ and column $j$ is denoted by $(i, j)$. Each cell can either be occupied or empty.

You need to place four control towers (numbered from 1ドル$ to 4ドル$), each in a different empty cell. To allow easier communication between different towers, for all $k = 1, 2, 3,ドル you want tower $k$ and tower $k + 1$ to be placed either in the same row or in the same column.

You want to calculate the number of ways to place the control towers to satisfy the requirements above. Two ways are considered different if there exists $k$ where control tower $k$ is placed in different cells.

입력

The first line of input contains two integers $r$ and $c$ (1ドル ≤ r, c ≤ 2000$). Each of the next $r$ lines contains a string of $c$ characters. The $j$-th character in the $i$-th line is # if cell $(i, j)$ is occupied; otherwise, it is . (dot).

출력

Output the number of ways to place the control towers to satisfy the requirements above.

제한

예제 입력 1

3 4
.#.#
#...
.###

예제 출력 1

10

Figure A.1 illustrates all 10ドル$ possible ways to place the control towers, where the cells numbered 1ドル,ドル 2ドル,ドル 3ドル,ドル and 4ドル$ represent control towers 1ドル,ドル 2ドル,ドル 3ドル,ドル and 4ドル$ respectively.

Figure A.1: All 10ドル$ possible ways to place the control towers.

예제 입력 2

4 6
######
#.#.#.
.#.#.#
######

예제 출력 2

0

It is impossible for any control tower in row 2ドル$ to be in the same column as any control tower in row 3ドル$. Since there are not enough empty cells to place all four control towers in the same row, there is no way to place the control towers to satisfy the requirements above.

예제 입력 3

1 10
..........

예제 출력 3

5040

All 10ドル \times 9 \times 8 \times 7 = 5040$ ways of control tower positions satisfy the requirements above.

예제 입력 4

1 10
##########

예제 출력 4

0

There is no empty cell to place any control tower.

노트

출처

ICPC > Regionals > Asia Pacific > Asia Pacific Championship > The 2025 ICPC Asia Pacific Championship A번

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

출처

대학교 대회

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

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