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 pii pair<int,int>
#define ll long long
using namespace std;
int main()
{
int h,w;
cin>>h>>w;
ll os[h][w]={},is[h][w]={};
int js[h][w]={};
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
char c;cin>>c;
if(c=='J')js[i][j]=1;
else if(c=='O')os[i][j]=1;
else is[i][j]=1;
}
}
for(int i=1;i<h;i++)
for(int j=0;j<w;j++)is[i][j]+=is[i-1][j];
for(int i=0;i<h;i++)
for(int j=1;j<w;j++)os[i][j]+=os[i][j-1];
ll ans=0;
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
if(js[i][j])
{
ans+=(is[h-1][j]-is[i][j])*(os[i][w-1]-os[i][j]);
}
}
}
cout<<ans<<endl;
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... |