제출 #542823

#제출 시각아이디문제언어결과실행 시간메모리
542823FystyBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
188 ms159992 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...