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;
using ll = long long;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll h,w;
cin >> h >> w;
vector<string> a(h);
for(auto &o : a) cin >> o;
vector<vector<ll>> b(h,vector<ll>(w,0)),c(h,vector<ll>(w,0));
ll ans = 0;
for(ll j = w-1;j>=0;j--){
for(ll i = h-1;i>=0;i--){
if (a[i][j]=='O') b[i][j]++;
if (j<w-1) b[i][j]+=b[i][j+1];
if (a[i][j]=='I') c[i][j]++;
if (i<h-1) c[i][j]+=c[i+1][j];
if (a[i][j]=='J') ans += b[i][j]*c[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... |