Submission #1049586

#TimeUsernameProblemLanguageResultExecution timeMemory
1049586vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
149 ms161624 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define fi first
#define se second
#define sst string
#define pb push_back
#define maxco 100000+5
#define lld long double
#define cha ios_base::sync_with_stdio(false);
#define ffl cout.flush();
#define phi acos(-1)
#define mr make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define pqin priority_queue<ll,vector<ll>,greater<>>
#define pqpair priority_queue<pair<ll,ll> ,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define pqpair2 priority_queue<pair<pair<ll,ll>,pair<ll,ll>>,vector<pair<pi,pair<ll,ll>>>,greater<pair<pi,pair<ll,ll>>>>
#define INF 1000000009
#define MAXN 1000006
#define pii pair<ll,ll>
 
#define mod 998244353


ll h,w;
sst s[3003];
ll ps1[3003][3003],ps2[3003][3003];

int main(){
    cin>>h>>w;
    REP(i,0,h-1)cin>>s[i];
    REP(i,0,h-1){
        REP(j,0,w-1){
            ll bci=max((ll)0,i-1ll);
            ll bcj=max((ll)0,j-1ll);
            ps2[i][j]+=ps2[i][bcj]+(s[i][j]=='O');
            ps1[i][j]+=ps1[bci][j]+(s[i][j]=='I');
        }
    }
    ll ans=0;
    REP(i,0,h-1){
        REP(j,0,w-1){
            if(s[i][j]=='J'){
                ans+=(ps1[h-1][j]-ps1[i][j])*(ps2[i][w-1]-ps2[i][j]);
            }
        }
    }
    cout<<ans<<endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...