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 ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
const int maxn=3005;
ll h,w,a[maxn][maxn],b[maxn][maxn];
string s[maxn];
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> h >> w;
for(int i=0;i<h;i++){
cin >> s[i];
}
ll ans=0;
for(int i=h-1;i>=0;i--){
for(int j=w-1;j>=0;j--){
a[i][j]=a[i+1][j];
b[i][j]=b[i][j+1];
if(s[i][j]=='I') a[i][j]++;
else if(s[i][j]=='O') b[i][j]++;
else ans+=a[i][j]*b[i][j];
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |