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;
int main(int argc, char const *argv[]){
int h, w;
cin >> h >> w;
char grid[h][w];
for(int i = 0; i < h; i++){
for(int k = 0; k < w; k++)
cin >> grid[i][k];
}
int ingot[h][w] = {0}, orb[h][w] = {0};
for(int i = 0; i < w; i++){
int counter = 0;
for(int k = h - 1; k >= 0; k--){
if(grid[k][i] == 'I')
counter++;
ingot[k][i] = counter;
}
}
for(int i = 0; i < h; i++){
int counter = 0;
for(int k = w - 1; k >= 0; k--){
if(grid[i][k] == 'O')
counter++;
orb[i][k] = counter;
}
}
int res = 0;
for(int i = 0; i < h; i++){
for(int k = 0; k < w; k++){
if(grid[i][k] == 'J')
res += orb[i][k] * ingot[i][k];
}
}
cout << res;
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... |