#include <algorithm>
#include <iostream>
using namespace std;
const int N = 3000;
const int M = 3000;
char cc[N][M + 1];
int aa[N][M], bb[N][M];
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
int n, m; cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> cc[i];
for (int i = 0; i < n; i++)
for (int a = 0, j = m - 1; j >= 0; j--)
aa[i][j] = a += cc[i][j] == 'O';
for (int j = 0; j < m; j++)
for (int b = 0, i = n - 1; i >= 0; i--)
bb[i][j] = b += cc[i][j] == 'I';
long long k = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (cc[i][j] == 'J')
k += aa[i][j] * bb[i][j];
cout << k << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |