#include <bits/stdc++.h>
using namespace std;
const int nx = 3e3+5;
int h, w;
long long orb[nx][nx], ingot[nx][nx];
char s[nx][nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin >> h >> w;
for(int i=1;i<=h;i++)
for(int j=1;j<=w;j++)
cin >> s[i][j];
for(int i=1;i<=h;i++) {
for(int j=1;j<=w;j++) {
if(s[i][j] == 'O')
orb[i][j]++;
orb[i][j] += orb[i][j - 1];
}
}
for(int i=1;i<=h;i++) {
for(int j=1;j<=w;j++) {
if(s[i][j] == 'I')
ingot[i][j]++;
ingot[i][j] += ingot[i - 1][j];
}
}
long long res = 0;
for(int i=1;i<=h;i++) {
for(int j=1;j<=w;j++) {
if(s[i][j] == 'J') {
res += (orb[i][w] - orb[i][j]) * (ingot[h][j] - ingot[i][j]);
}
}
}
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... |