#include <bits/stdc++.h>
using namespace std;
int h, w, ing[3010][3010], orb[3010][3010];
long long ans;
char arr[3010][3010];
int main() {
cin >> h >> w;
for(int i=1; i<=h; i++) {
for(int j=1; j<=w; j++) {
cin >> arr[i][j];
}
}
for(int i=1; i<=h; i++) {
for(int j=1; j<=w; j++) {
if(arr[i][j] == 'O') orb[i][j]++;
if(arr[i][j] == 'I') ing[i][j]++;
orb[i][j] += orb[i][j-1];
ing[i][j] += ing[i-1][j];
}
}
for(int i=1; i<=h; i++) {
for(int j=1; j<=w; j++) {
if(arr[i][j] != 'J') continue;
ans += (orb[i][w]-orb[i][j])*(ing[h][j]-ing[i][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... |