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;
int h,w;
string grid[3005];
long long qs1[3005][3005],qs2[3005][3005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> h >> w;
for(int i=1;i<=h;i++){
string s;
cin >> s;
s=" "+s;
grid[i]=s;
}
memset(qs1,0,sizeof(qs1));
memset(qs2,0,sizeof(qs2));
for(int i=1;i<=h;i++){
for(int j=w;j>=1;j--){
qs1[i][j]=qs1[i][j+1]+(grid[i][j]=='O');
}
}
for(int i=h;i>=1;i--){
for(int j=1;j<=w;j++){
qs2[i][j]=qs2[i+1][j]+(grid[i][j]=='I');
}
}
long long ans=0;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
if(grid[i][j]=='J'){
ans+=qs1[i][j]*qs2[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... |