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 ans[3005][3005];
char arr[3005][3005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m;
cin >> n >> m;
vector<pair<int,int>> list;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> arr[i][j];
}
}
for(int j = m-1; j >= 0; j--){
int o = 0;
for(int i = n-1; i >= 0; i--){
if(arr[i][j] == 'I') o++;
if(arr[i][j] == 'J') {
ans[i][j] = o;
}
}
}
for(int i = n-1; i >= 0; i--){
int o = 0;
for(int j = m-1; j >= 0; j--){
if(arr[i][j] == 'O') o++;
if(arr[i][j] == 'J') {
list.push_back(make_pair(i,j));
ans[i][j] *= o;
}
}
}
long long int ansss = 0;
for(int i = 0; i < (int)list.size(); i++) ansss += ans[list[i].first][list[i].second];
cout << ansss << 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... |