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 n,m,no[3004][3004],ni[3004][3004],anw;
vector<string> ar;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
for(int i=0;i<n;i++)
{
string a;cin>>a;
ar.push_back(a);
}
for(int i=0;i<n;i++)
{
ll sum=0;
for(int j=m-1;j>=0;j--)
{
if(ar[i][j]=='O')
sum++;
no[i][j]=sum;
}
}
for(int i=0;i<m;i++)
{
ll sum=0;
for(int j=n-1;j>=0;j--)
{
if(ar[j][i]=='I')
sum++;
ni[j][i]=sum;
}
}
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(ar[i][j]=='J')
anw+=ni[i][j]*no[i][j];
cout<<anw;
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... |