#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll h, w;
string s[3005];
ll to[3005][3005];
ll ti[3005][3005];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> h >> w;
for (int i = 1; i <= h; i++)
{
cin >> s[i];
s[i] = " " + s[i];
}
for (int i = h; i >= 1; i--)
{
for (int j = w; j >= 1; j--)
{
to[i][j] = to[i][j + 1] + (s[i][j] == 'O');
ti[i][j] = ti[i + 1][j] + (s[i][j] == 'I');
}
}
ll kq = 0;
for (int i = 1; i <= h; i++)
{
for (int j = 1; j <= w; j++)
{
if (s[i][j] == 'J')
{
kq += to[i][j] * ti[i][j];
}
}
}
cout << kq;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |