제출 #899340

#제출 시각아이디문제언어결과실행 시간메모리
899340jocccccaBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
405 ms154812 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;


int prefo[3000][3000];
int prefi[3000][3000];
signed main()
{
    int n,m;

    cin>>n>>m;
    char a[n][m];

    for(int i=0; i < n; i++)
        for(int j=0; j < m;j++)
            cin >> a[i][j];


    for(int i=0; i<n;i++) {
        for(int j=0; j<m; j++) {
            if(a[i][j] == 'I'){
                prefi[i][j]++;
            }
            if(a[i][j] == 'O'){
                prefo[i][j]++;
            }
        }
    }
     for(int i=0; i < n; i++){
        for(int j=0; j < m;j++){
           prefo[i][j] += prefo[i][j - 1];

        }

    }
    for(int i=0; i < n; i++){
        for(int j=0; j < m;j++){
            prefi[i][j] += prefi[i - 1][j];

        }

    }
    long long rez=0;
    long long brI=0;
    long long brO=0;


    /* for(int i=0; i < n; i++){
        for(int j=0; j < m;j++){
           cout<<prefi[i][j]<< " ";
        }
        cout<<"\n";
    }
    cout<<"\n";
     for(int i=0; i < n; i++){
        for(int j=0; j < m;j++){
           cout<<prefo[i][j]<< " ";
        }
        cout<<"\n";
    }
    cout<<"\n";*/



    for(int i=0; i < n; i++){
        for(int j=0; j < m;j++){
            if(a[i][j]=='J'){
                brI = prefi[n-1][j] - prefi[i][j];
                brO = prefo[i][m-1] - prefo[i][j];

                rez+=brI*brO;
            }

        }
    }
    cout<<rez;

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...