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

16980번 - Bitaro the Brave 서브태스크다국어

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

문제

Bitaro the Brave faces the Devil.

Bitaro is going to attack the Devil by arranging jewels, orbs and ingots on an H times W grid and casting a spell. The square at the i-th row (1 ≤ i ≤ H) from the top and the j-th column (1 ≤ j ≤ W) from the left is denoted by (i, j).

Now, Bitaro has arranged one of these three types on each square. Bitaro is going to cast a spell, the power of which is determined by the arrangement of jewels, orbs and ingots. Specifically, the power equals to the number of quadruplets of integers (i, j, k, l) (1 ≤ i < k ≤ H, 1 ≤ j < l ≤ W) satisfying the following condition.

Condition: Bitaro has arranged a jewel on the square (i, j), an orb on the square (i, l) and an ingot on the square (k, j).

Bitaro is wondering the power of the spell.

Write a program which, given the arrangement of jewels, orbs and ingots, calculates the power of the spell Bitaro casts.

입력

Read the following data from the standard input.

H W
S1
:
SH

Si (1 ≤ i ≤ H) is a string of length W. The item arranged on the square (i, j) (1 ≤ j ≤ W) is a jewel if the j-th character of Si is J, an orb if it is O and an ingot if it is I.

출력

Write one line to the standard output. The output should contain the power of the spell Bitaro casts.

제한

  • 2 ≤ H ≤ 3 000.
  • 2 ≤ W ≤ 3 000.
  • Si is a string of length W (1 ≤ i ≤ H).
  • Each character of Si is J, O, or I (1 ≤ i ≤ H).

서브태스크

번호배점제한
120

H ≤ 100, W ≤ 100.

230

H ≤ 500, W ≤ 500.

350

No additional constraints.

예제 입력 1

3 4
JOIJ
JIOO
IIII

예제 출력 1

3

In this sample, 3 quadruplets (i, j, k, l) = (1, 1, 3, 2), (2, 1, 3, 3), (2, 1, 3, 4) satisfy the condition, so you should output 3.

예제 입력 2

4 4
JJOO
JJOO
IIJO
IIIJ

예제 출력 2

17

힌트

출처

Olympiad > Japanese Olympiad in Informatics > JOI 2018/2019 1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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