Submission #1258763

#TimeUsernameProblemLanguageResultExecution timeMemory
1258763ngonamkhanhBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
123 ms150596 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...