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 int long long
using namespace std;
int sufw[3010][3010],sufh[3010][3010];
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int h,w,res=0;
cin>>h>>w;
string a[h];
for(int i=0;i<h;i++)cin>>a[i];
for(int i=0;i<w;i++){
for(int j=h-1;j>=0;j--){
sufh[j][i]=sufh[j+1][i]+(a[j][i]=='I');
}
}
for(int i=0;i<h;i++){
for(int j=w-1;j>=0;j--){
sufw[i][j]=sufw[i][j+1]+(a[i][j]=='O');
}
}
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(a[i][j]!='J')continue;
res+=sufh[i][j]*sufw[i][j];
}
}
cout<<res<<'\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... |