This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int nbO[3001][3001];
int nbI[3001][3001];
string terrain[3000];
int main() {
ios_base::sync_with_stdio(false);
int nbLigs, nbCols;
cin >> nbLigs >> nbCols;
for(int iLig = 0;iLig < nbLigs;iLig++) {
cin >> terrain[iLig];
}
for(int iLig = 0;iLig < nbLigs;iLig++) {
for(int iCol = nbCols - 1;iCol >= 0;iCol--) {
nbO[iLig][iCol] = nbO[iLig][iCol + 1] + (terrain[iLig][iCol] == 'O');
}
}
for(int iCol = 0;iCol < nbCols;iCol++) {
for(int iLig = nbLigs - 1;iLig >= 0;iLig--) {
nbI[iLig][iCol] = nbI[iLig + 1][iCol] + (terrain[iLig][iCol] == 'I');
}
}
long long total = 0;
for(int iLig = 0;iLig < nbLigs;iLig++) {
for(int iCol = 0;iCol < nbCols;iCol++) {
if(terrain[iLig][iCol] == 'J') {
total += nbO[iLig][iCol] * (long long) nbI[iLig][iCol];
}
}
}
cout << total << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |