Submission #588303

#TimeUsernameProblemLanguageResultExecution timeMemory
588303n_m_pBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
224 ms159628 KiB
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define infi INT_MAX
#define rinfi INT_MIN
#define inf LLONG_MAX
#define rinf LLONG_MIN
#define ff first
#define ss second
#ifdef LOCAL
#include"debug.h"
#else
#define line
#define debug(x...)
#endif
using namespace std;
main()
{   
    fast
    int tc=1,i,j,k;
    //cin>>tc;
    while(tc--)
    {
      int a,b;
      cin>>a>>b;
      string s[a];
      for(i=0;i<a;i++)
        cin>>s[i];
     int r[a][b],c[a][b];
     for(i=0;i<a;i++)
     {
        for(j=0;j<b;j++)
        {
            r[i][j]=c[i][j]=0;
            if(s[i][j]=='I')
            {
                r[i][j]=1;
            }
            if(s[i][j]=='O')
            {
                c[i][j]=1;
            }
        }
     }
     for(i=0;i<a;i++)
     {
        for(j=b-2;j>=0;j--)
        {
           c[i][j]+=c[i][j+1];
        }
     }
      for(i=a-2;i>=0;i--)
     {
        for(j=0;j<b;j++)
        {
           r[i][j]+=r[i+1][j];
        }
     }
     int ans=0;
     for(i=0;i<a;i++)
     {
        for(j=0;j<b;j++)
        {
            if(s[i][j]=='J')
            {
                ans+=(r[i][j]*c[i][j]);
            }
        }
     }
     cout<<ans<<endl;

    }
}

Compilation message (stderr)

joi2019_ho_t1.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main()
      | ^~~~
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:21:18: warning: unused variable 'k' [-Wunused-variable]
   21 |     int tc=1,i,j,k;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...