# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
529338 | smth | Bitaro the Brave (JOI19_ho_t1) | C++14 | 315 ms | 180036 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<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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |