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;
#define int long long
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int h,w;
cin >> h >> w;
char a[h][w];
for(int i=0; i<h; ++i) {
for(int j=0; j<w; ++j) cin >> a[i][j];
}
int ans=0;
int cnt[w]; memset(cnt,0,sizeof(cnt));
for(int i=h-1; i>=0; --i) {
int curr=0;
for(int j=w-1; j>=0; --j) {
if(a[i][j]=='O') ++curr;
else if(a[i][j]=='I') {
++cnt[j];
}
else ans+=cnt[j]*curr;
}
}
cout << ans;
}
/*
6
4 1
1 5
10 3
9 1
4 2
5 3
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |