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;
void PlayGround() {
int n, m;
cin>>n>>m;
char c[n+2][m+2];
for(int i=1; i<=n; ++i) {
for(int j=1; j<=m; ++j) {
cin>>c[i][j];
}
}
long long O[n+2][m+2];
long long I[n+2][m+2];
memset(O, 0, sizeof O);
memset(I, 0, sizeof I);
for(int i=1; i<=n; ++i) {
for(int j=1; j<=m; ++j) {
if(c[i][j]=='O') O[i][j] = 1;
else if(c[i][j]=='I') I[i][j] = 1;
}
}
for(int i=1; i<=n; ++i) {
for(int j=m; j>0; --j) {
O[i][j] += O[i][j+1];
}
}
for(int j=1; j<=m; ++j) {
for(int i=n; i>0; --i) {
I[i][j] += I[i+1][j];
}
}
long long ans = 0;
for(int i=1; i<=n; ++i) {
for(int j=1; j<=m; ++j) if(c[i][j]=='J') {
ans += O[i][j+1] * I[i+1][j];
}
}
cout<<ans<<'\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
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... |