Submission #680441

#TimeUsernameProblemLanguageResultExecution timeMemory
680441tigarBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
444 ms161532 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll os[3003][3003], is[3003][3003];

int main()
{
    int H, W;
    cin>>H>>W;
    string rows[3003];
    for(int i=0; i<H; i++)cin>>rows[i];

    for(int i=0; i<H; i++)
    {
        int cnt=0;
        for(int j=W-1; j>=0; j--)
        {
            os[i][j]=cnt;
            if(rows[i][j]=='O')cnt++;
        }
    }

    for(int i=0; i<W; i++)
    {
        int cnt=0;
        for(int j=H-1; j>=0; j--)
        {
            is[j][i]=cnt;
            if(rows[j][i]=='I')cnt++;
        }
    }
    ll rezz=0;
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            if(rows[i][j]=='J')rezz+=os[i][j]*is[i][j];
            //cout<<os[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<rezz;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...