제출 #1355113

#제출 시각아이디문제언어결과실행 시간메모리
1355113nataliaaBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
266 ms82268 KiB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    int p1[h][w]={}, p2[h][w]={};
    for(int i = 0; i < h; i++) {
        cin >> s[i];
        
    }
    for(int i = 0; i < h; i++){
        for(int j = w-1; j>=0; j--){
            if(j!=w-1) p1[i][j] = p1[i][j+1];
            if(s[i][j]=='O') p1[i][j]++;
        }
    }
    for(int j = 0; j < w; j++){
        for(int i = h-1; i>=0; i--){
            if(i!=h-1) p2[i][j] = p2[i+1][j];
            if(s[i][j]=='I') p2[i][j]++;
        }
    }
    // for(int i = 0; i < h; i++) cout << p1[i]<<" ";
    // cout << endl;
    // for(int i = 0; i < w; i++) cout << p2[i]<<" ";
    // cout << endl;
    long long ans = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j]=='J'){
                //cout << i << " "<< j << endl;
                ans+=p2[i][j]*p1[i][j];
            }
        }
    }
    cout << ans;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…