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;
typedef long long ll;
typedef pair<int,int> pii;
int n,m;
char A[3005][3005];
pii B[3005][3005];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>A[i][j];
for(int i=1;i<=n;i++) {
for(int j=m;j>=1;j--) {
B[i][j].first = B[i][j+1].first + (A[i][j] == 'O');
}
}
for(int i=n;i>=1;i--) {
for(int j=1;j<=m;j++) {
B[i][j].second = B[i+1][j].second + (A[i][j] == 'I');
}
}
ll ans = 0;
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
if(A[i][j] == 'J') {
ans += B[i][j].first * B[i][j].second;
}
}
}
cout<<ans;
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... |