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>
#define ll long long
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l,ans;
ll A[5003][5003],B[5003][5003];
string s[5003];
int main() {
cin>>n>>m;
for(ll i=1;i<=n;i++) {
cin>>s[i];
a=0;
for(ll j=m-1;j>=0;j--) {
if(s[i][j]=='O') { a++; }
A[i][j]=a;
}
}
for(ll i=0;i<m;i++) {
a=0;
for(ll j=n;j>=1;j--) {
if(s[j][i]=='I') a++;
B[j][i]=a;
}
}
for(ll i=1;i<=n;i++) {
for(ll j=0;j<m;j++) {
if(s[i][j]=='J') { ans+=A[i][j]*B[i][j]; }
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |