제출 #1258738

#제출 시각아이디문제언어결과실행 시간메모리
1258738nasufyroBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
117 ms10304 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll h, w;
    cin >> h >> w;
    vector<string> board(h+5);
    for(ll i = 0; i < h; i++){
        cin >> board[i];
    }
    ll ans=0;
    vector<ll> col(w+5, 0);
    vector<ll> suf(w+5, 0);
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            if(board[i][j]=='I')
            {
                col[j]++;
            }
        }
    }
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            if(board[i][j]=='I')
            {
                col[j]--;
            }
        }
        suf[w] = 0;
        for(ll j=w-1;j>=0;j--)
        {
            suf[j] = suf[j+1] + (board[i][j]=='O');
        }
        for(ll j=0;j<w;j++)
        {
            if(board[i][j]=='J')
            {
                ans += col[j] * suf[j+1];
            }
        }
    }
    cout<<ans;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...