#include <bits/stdc++.h>
using namespace std;
const int N = 3333;
string tb[N];
int n, m, pf[2][N][N];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i = 1;i<=n;i++){
cin >> tb[i];
tb[i] = " " + tb[i];
for(int j = 1;j<=m;j++){
pf[0][i][j] = pf[0][i][j - 1] + (tb[i][j] == 'O');
pf[1][i][j] = pf[1][i - 1][j] + (tb[i][j] == 'I');
}
}
long long ans = 0;
for(int i = 1;i<=n;i++){
for(int j = 1;j<=m;j++){
if(tb[i][j] == 'J'){
ans += (pf[0][i][m] - pf[0][i][j]) * (pf[1][n][j] - pf[1][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... |