#include<bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using aa = array<int,3>;
const int N = 3005;
int n, m, cur, ans = 0;
int pre[N][N];
char a[N][N];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin >> n >> m;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++) cin >> a[i][j];
}
for (int i = 1; i <= n; i++){
cur = 0;
for (int j = m; j >= 1; j--){
if (a[i][j] == 'O') cur++;
pre[i][j] = pre[i-1][j];
if (a[i][j] == 'J') pre[i][j] += cur;
}
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
if (a[i][j] == 'I') ans += pre[i-1][j];
}
}
cout << ans;
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... |