Submission #1258011

#TimeUsernameProblemLanguageResultExecution timeMemory
1258011motionBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
498 ms80012 KiB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int h,w;
    cin>>h>>w;
    vector<vector<char>> grid(h,vector<char>(w));
    vector<vector<int>> INGOT(h,vector<int>(w,0)),ORB(h,vector<int>(w,0));
    for(int i=0;i<h;i++)
    {
        int O=0;
        for(int j=0;j<w;j++)
        {
            cin>>grid[i][j];
        }
    }
    for(int i=0;i<h;i++)
    {

        for(int j=w-1;j>=0;j--)
        {
            if(j<w-1)
            {
                ORB[i][j]+=ORB[i][j+1];
            }
            if(grid[i][j]=='O') ORB[i][j]++;
        }
    }
    for(int i=0;i<w;i++)
    {
        for(int j=h-1;j>=0;j--)
        {
            if(j<h-1)
            {
                INGOT[j][i]+=INGOT[j+1][i];
            }
            if(grid[j][i]=='I') INGOT[j][i]++;
        }
    }
    long long ans=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(grid[i][j]=='J')
            {
                ans+=ORB[i][j]*INGOT[i][j];
            }
        }
    }
    cout<<ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...