Submission #109524

#TimeUsernameProblemLanguageResultExecution timeMemory
109524ArturgoBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
347 ms80908 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...