#include <bits/stdc++.h>
using namespace std;
char a[3005][3005];
long long row[3005];
long long col[3005];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int h,w;
cin >> h >> w;
for(int i = 1;i<=h;i++){
for(int j = 1;j<=w;j++){
cin >> a[i][j];
}
}
long long res = 0;
for(int i = h;i>=1;i--){
for(int j = w;j>=1;j--){
if(a[i][j] == 'J') res += row[i] * col[j];
if(a[i][j] == 'I') col[j]++;
if(a[i][j] == 'O') row[i]++;
}
}
cout << res << '\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... |