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 ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll ans=0;
const int MAX=3005;
char tab[MAX][MAX];
int sufo[MAX][MAX];
int sufi[MAX][MAX];
int32_t main()
{
BOOST;
int n,m;
cin>>n>>m;
for (int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>tab[i][j];
for (int i=1;i<=n;i++)
for (int j=m;j>=1;j--)
sufo[i][j]=sufo[i][j+1]+(tab[i][j]=='O');
for (int i=1;i<=m;i++)
for (int j=n;j>=1;j--)
sufi[i][j]=sufi[i][j+1]+(tab[j][i]=='I');
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
if (tab[i][j]=='J')
ans+=(ll)sufo[i][j]*sufi[j][i];
cout<<ans;
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... |