#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3000;
char mat[MAX_N][MAX_N];
int frecvCol[MAX_N];
int main() {
int n, m;
cin >> n >> m;
for ( int l = 0; l < n; l++ ) {
for ( int c = 0; c < m; c++ )
cin >> mat[l][c];
}
long long ans = 0;
for ( int l = n - 1; l >= 0; l-- ) {
int frecvLin = 0;
for ( int c = m - 1; c >= 0; c-- ) {
if ( mat[l][c] == 'J' )
ans += frecvLin * frecvCol[c];
else if ( mat[l][c] == 'O' )
frecvLin++;
else
frecvCol[c]++;
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |