# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471477 | fuad27 | Bitaro the Brave (JOI19_ho_t1) | C++17 | 0 ms | 0 KiB |
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
int main () {
int h, w;
cin >> h >> w;
string v[h];
for(int i = 0;i<h;i++)cin>>v[i];
int cnt[w] = {0}, ans = 0, k = 0;
for(int i = h-1;i>=0;i--) {
k = 0;
for(int j = w-1;j>=0;j--) {
if(v[i][j] == 'J')ans+=cnt[j]*k;
else if(v[i][j] == 'O')k++;
else cnt[j]++;
}
}
cout<<ans<<endl;
}