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 <bits/stdc++.h>
using namespace std;
struct squarePower {
long long int I = 0, O = 0;
long long int result() {
return I*O;
}
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int h, w;
cin >> h >> w;
char grid[h][w];
squarePower puissance[h][w];
for(int loop = 0; loop < h; ++loop) {
for(int looping = 0; looping < w; ++looping) {
cin >> grid[loop][looping];
}
}
for(int loop = 0; loop < w; ++loop) {
int nbI = 0;
for(int looping = h-1; looping >= 0; --looping) {
if(grid[looping][loop] == 'I') {
nbI++;
}
else if(grid[looping][loop] == 'J') {
puissance[looping][loop].I = nbI;
}
}
}
for(int loop = 0; loop < h; ++loop) {
int nbO = 0;
for(int looping = w-1; looping >= 0; --looping) {
if(grid[loop][looping] == 'O') {
nbO++;
}
else if(grid[loop][looping] == 'J') {
puissance[loop][looping].O = nbO;
}
}
}
long long int somme = 0;
for(int loop = 0; loop < h; ++loop) {
for(int looping = 0; looping < w; ++looping) {
somme += puissance[loop][looping].result();
}
}
cout << somme;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |