#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define mp make_pair
#define fi first
#define se second
ll H, W, os[3010][3010], is[3010][3010];
char s[3010][3010];
int main() {
cin >> H >> W;
for (int i = 1; i <= H; i++) {
os[i][0] = 0;
for (int j = 1; j <= W; j++) {
cin >> s[i][j];
os[i][j] = os[i][j-1] + (s[i][j] == 'O');
}
}
for (int j = 1; j <= W; j++) {
is[0][j] = 0;
for (int i = 1; i <= H; i++) {
is[i][j] = is[i-1][j] + (s[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 1; i < H; i++) {
for (int j = 1; j < W; j++) {
if (s[i][j] != 'J') continue;
ans += (os[i][W] - os[i][j])*(is[H][j] - is[i][j]);
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |