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;
#define MAX 3010
string s[MAX];
int h, w, v1[MAX][MAX], v2[MAX][MAX];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> h >> w;
for(int i = 0; i < h; i++)
cin >> s[i];
int qt = 0;
for(int j = 0; j < w; j++){
qt = 0;
for(int i = h-1; i >= 0; i--){
v1[i][j] += qt;
if(s[i][j] == 'I'){
qt++;
}
}
}
for(int i = 0; i < h; i++){
qt = 0;
for(int j = w-1; j >= 0; j--){
v2[i][j] += qt;
if(s[i][j] == 'O'){
qt++;
}
}
}
int ans = 0;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(s[i][j] == 'J'){
ans += v1[i][j]*v2[i][j];
}
}
}
cout << ans << "\n";
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... |