Submission #529338

#TimeUsernameProblemLanguageResultExecution timeMemory
529338smthBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
315 ms180036 KiB
#include<iostream>
#define endl '\n'
using namespace std;
char s[5005][5005];
long long row[5005][5005], col[5005][5005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin.tie(0);

    long long n,h,w,i,j;

    cin>>h>>w;

    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            cin>>s[i][j];
            if(s[i][j]=='O')row[i][j]=1;
            if(s[i][j]=='I')col[i][j]=1;
        }
    }
    for(i=h-1;i>=0;i--)
    {
        for(j=w-1;j>=0;j--)
        {
            col[i][j]+=col[i+1][j];
            row[i][j]+=row[i][j+1];
        }
    }
    long long ans=0;

    for(i=h-1;i>=0;i--)
    {
        for(j=w-1;j>=0;j--)
        {
           if(s[i][j]=='J')ans+=col[i][j]*row[i][j];
        }
    }
    cout<<ans<<endl;




}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:12:15: warning: unused variable 'n' [-Wunused-variable]
   12 |     long long n,h,w,i,j;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...