제출 #207827

#제출 시각아이디문제언어결과실행 시간메모리
207827kai824Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
393 ms151288 KiB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

string mp[3005];

ll i_cnt[3005][3005];
ll o_cnt[3005][3005],ans;

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    int h,w;
    cin>>h>>w;
    for(int x=0;x<h;x++){
      cin>>mp[x];
    }
    for(int x=0;x<h;x++){
      for(int i=w-1;i>=0;i--){
        o_cnt[x][i]=o_cnt[x][i+1];
        if(mp[x][i]=='O')o_cnt[x][i]++;
      }
    }
    for(int x=0;x<w;x++){
      for(int i=h-1;i>=0;i--){
        i_cnt[i][x]=i_cnt[i+1][x];
        if(mp[i][x]=='I')i_cnt[i][x]++;
      }
    }
    for(int x=0;x<h;x++){
      for(int y=0;y<w;y++){
        if(mp[x][y]=='J')ans+=o_cnt[x][y+1]*i_cnt[x+1][y];
      }
    }
    cout<<ans<<'\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...