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;
#define ll long long
#define pii pair<int, int>
#define oo 1e9
#define pb push_back
const int MAX = 3003;
int n, m;
char arr[MAX][MAX];
int sufOrb[MAX][MAX];
int sufIng[MAX][MAX];
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
string a; cin >> a;
for(int j = 0; j < m; j++){
arr[i][j + 1] = a[j];
}
}
for(int i = 1; i <= n; i++){
for(int j = m; j >= 1; j--){
sufOrb[i][j] = sufOrb[i][j + 1] + (arr[i][j] == 'O');
}
}
for(int j = 1; j <= m; j++){
for(int i = n; i >= 1; i--){
sufIng[i][j] = sufIng[i + 1][j] + (arr[i][j] == 'I');
}
}
ll ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(arr[i][j] == 'J'){
ans += 1ll * sufOrb[i][j] * sufIng[i][j];
}
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |