#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3003, inf = 2e9;
int h, w, pfo[N][N], pfi[N][N];
char a[N][N];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen(".INP", "r", stdin);
// freopen(".OUT", "w", stdout);
cin >> h >> w;
for (int i=1;i<=h;++i) {
for (int j=1;j<=w;++j) {
cin >> a[i][j];
pfo[i][j] = pfo[i][j - 1] + (a[i][j] == 'O');
pfi[i][j] = pfi[i - 1][j] + (a[i][j] == 'I');
}
}
ll ans = 0;
for (int i=1;i<=h;++i) {
for (int j=1;j<=w;++j) {
if (a[i][j] == 'J') {
ans += (pfo[i][w] - pfo[i][j]) * (pfi[h][j] - pfi[i][j]);
}
}
}
cout << ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |