#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 100;
char t[maxn][maxn];
int I[maxn][maxn], O[maxn][maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
cin >> t[i][j];
}
}
for (int i = n;i;i--)
{
for (int j = 1;j <= m;j++)
{
I[i][j] = I[i + 1][j] + (t[i][j] == 'I');
}
}
for (int i = 1;i <= n;i++)
{
for (int j = m;j;j--)
{
O[i][j] = O[i][j + 1] + (t[i][j] == 'O');
}
}
long long int ans = 0;
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
ans += O[i][j] * I[i][j] * (t[i][j] == 'J');
}
}
cout << ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |