Submission #698163

#TimeUsernameProblemLanguageResultExecution timeMemory
698163RichemBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
604 ms110020 KiB
#include <iostream>
using namespace std;

const int MAX_TAILLE = 4200;

int nbLigne, nbCol;
char grille[MAX_TAILLE][MAX_TAILLE];

int cumulO[MAX_TAILLE][MAX_TAILLE] = {0};
int cumulI[MAX_TAILLE][MAX_TAILLE] = {0};

void input() {
    cin >> nbLigne >> nbCol;

    for(int lig = 0; lig < nbLigne; lig++) {
        for(int col = 0; col < nbCol; col++) {
            cin >> grille[lig][col];
            cumulO[lig][col+1] = cumulO[lig][col];
            cumulI[lig+1][col] = cumulI[lig][col];

            if(grille[lig][col] == 'O') {
                cumulO[lig][col+1]++;
            }
            if(grille[lig][col] == 'I') {
                cumulI[lig+1][col]++;
            }
        }
    }
}

long long total = 0;

int main() {
    input();

    for(int lig = 0; lig < nbLigne; lig++) {
        for(int col = 0; col < nbCol; col++) {
            if(grille[lig][col] != 'J') continue;

            total += ((cumulO[lig][nbCol] - cumulO[lig][col]) * (cumulI[nbLigne][col] - cumulI[lig][col]));
        }
    }

    cout << total << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...