This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define MAXH 3010
using namespace std;
char c[MAXH][MAXH];
ll cnto[MAXH][MAXH],cnti[MAXH][MAXH];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll h,w,ans=0;
    cin >> h >> w;
    for (ll i=1;i<=h;i++)
    {
        for (ll j=1;j<=w;j++)
            cin >> c[i][j];
    }
    for (ll i=1;i<=h;i++)
    {
        for (ll j=w;j>=1;j--)
            cnto[i][j]=cnto[i][j+1]+(c[i][j]=='O');
    }
    for (ll j=1;j<=w;j++)
    {
        for (ll i=h;i>=1;i--)
        {
            cnti[i][j]=cnti[i+1][j]+(c[i][j]=='I');
            if (c[i][j]=='J')
                ans+=cnto[i][j]*cnti[i][j];
        }
    }
    cout << ans;
    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... |