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;
string mp[3005];
ll i_cnt[3005][3005];
ll o_cnt[3005][3005],ans;
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(0);
int h,w;
cin>>h>>w;
for(int x=0;x<h;x++){
cin>>mp[x];
}
for(int x=0;x<h;x++){
for(int i=w-1;i>=0;i--){
o_cnt[x][i]=o_cnt[x][i+1];
if(mp[x][i]=='O')o_cnt[x][i]++;
}
}
for(int x=0;x<w;x++){
for(int i=h-1;i>=0;i--){
i_cnt[i][x]=i_cnt[i+1][x];
if(mp[i][x]=='I')i_cnt[i][x]++;
}
}
for(int x=0;x<h;x++){
for(int y=0;y<w;y++){
if(mp[x][y]=='J')ans+=o_cnt[x][y+1]*i_cnt[x+1][y];
}
}
cout<<ans<<'\n';
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... |