# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
588303 | n_m_p | Bitaro the Brave (JOI19_ho_t1) | C++17 | 224 ms | 159628 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |