#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 998244353
void solve()
{
int h, w;
cin >> h >> w;
string v[h];
for (int i = 0; i < h; i++)
cin >> v[i];
int cnt[w] = {0}, ans = 0, k = 0;
for (int i = h - 1; i >= 0; i--)
{
k = 0;
for (int j = w - 1; j >= 0; j--)
{
if (v[i][j] == 'J')
ans += cnt[j] * k;
else if (v[i][j] == 'O')
k++;
else
cnt[j]++;
}
}
cout << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t = 1;
// cin >> t;
for (ll i = 1; i <= t; i++)
{
solve();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |