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>
using namespace std;
typedef long long ll;
ll os[3003][3003], is[3003][3003];
int main()
{
int H, W;
cin>>H>>W;
string rows[3003];
for(int i=0; i<H; i++)cin>>rows[i];
for(int i=0; i<H; i++)
{
int cnt=0;
for(int j=W-1; j>=0; j--)
{
os[i][j]=cnt;
if(rows[i][j]=='O')cnt++;
}
}
for(int i=0; i<W; i++)
{
int cnt=0;
for(int j=H-1; j>=0; j--)
{
is[j][i]=cnt;
if(rows[j][i]=='I')cnt++;
}
}
ll rezz=0;
for(int i=0; i<H; i++)
{
for(int j=0; j<W; j++)
{
if(rows[i][j]=='J')rezz+=os[i][j]*is[i][j];
//cout<<os[i][j]<<" ";
}
//cout<<endl;
}
cout<<rezz;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |