#include <bits/stdc++.h>
#define int long long
using namespace std;
int h, w;
const int maxw = 3001;
int cntj[maxw];
string s[maxw];
signed main() {
cin >> h >> w;
for (int i = 0; i < h; i++)
cin >> s[i];
long long ans = 0;
for (int i = 0; i < w; i++)
cntj[i] = 0;
for (int i = 0; i < h; i++){
for (int j = 0; j < w; j++)
if (s[i][j] == 'O')
for (int k = 0; k < j; k++)
if (s[i][k] == 'J')
cntj[k]++;
for (int j = 0; j < w; j++)
if (s[i][j] == 'I')
ans += cntj[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... |