Submission #1150439

#TimeUsernameProblemLanguageResultExecution timeMemory
1150439tvgkBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
159 ms150492 KiB
#include<bits/stdc++.h>
using namespace std;
#define task "a"
#define se second
#define fi first
#define ll long long
#define ii pair<ll, ll>
const long mxN = 3e3 + 7;

ll Row[mxN][mxN], Col[mxN][mxN];
int nRow, nCol;
char chr[mxN][mxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(task".INP", "r", stdin);
    //freopen(task".OUT", "w", stdout);

    cin >> nRow >> nCol;
    for (int i = 1; i <= nRow; i++)
    {
        for (int j = 1; j <= nCol; j++)
            cin >> chr[i][j];
    }

    ll ans = 0;
    for (int i = nRow; i >= 1; i--)
    {
        for (int j = nCol; j >= 1; j--)
        {
            Row[i][j] = Row[i][j + 1] + (chr[i][j] == 'O');
            Col[i][j] = Col[i + 1][j] + (chr[i][j] == 'I');

            if (chr[i][j] == 'J')
                ans += Row[i][j] * Col[i][j];
        }
    }
    cout << ans;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...