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 f first
#define s second
#define pb push_back
using namespace std;
const int N=1005;
long long n,m,ans,sf1[N][N],sf[N][N];
char ch[N][N];
int main() {
cin>>n>>m;
for(int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
cin>>ch[i][j];
}
}
for (int i=1; i<=n; i++) {
for (int j=m; j>=1; j--) {
sf[i][j]=sf[i][j+1]+(ch[i][j]=='O');
}
}
for (int j=1; j<=m; j++) {
for (int i=n; i>=1; i--) {
sf1[i][j]=sf1[i+1][j]+(ch[i][j]=='I');
}
}
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
if (ch[i][j]!='J') continue;
ans+=sf[i][j+1]*sf1[i+1][j];
}
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |