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