# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471477 | 2021-09-09T13:20:29 Z | fuad27 | Bitaro the Brave (JOI19_ho_t1) | C++17 | 0 ms | 0 KB |
#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; }