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;
typedef pair<ll,ll> pll;
//#define int ll
#define MottoHayaku ios::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define uni(c) c.resize(distance(c.begin(),unique(c.begin(),c.end())))
#define unisort(c) sort(c.begin(),c.end());uni(c);
string s[3005];
ll co[3005][3005],ci[3005][3005];
signed main()
{
MottoHayaku
ll n,m;
cin>>n>>m;
rep(i,n) cin>>s[i];
rep(i,n)
{
rep(j,m)
{
if(s[i][j]=='O') co[i][j]=1;
else if(s[i][j]=='I') ci[i][j]=1;
}
}
for(int i=n-1;i>=0;i--)
{
for(int j=m-1;j>=0;j--)
{
co[i][j]+=co[i][j+1];
ci[i][j]+=ci[i+1][j];
}
}
ll ans=0;
rep(i,n)
{
rep(j,m)
{
if(s[i][j]!='J') continue;
ans+=co[i][j]*ci[i][j];
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |