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 ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()
int main(){
int n, m;
cin>>n>>m;
vector<vector<char>> mat(n, vector<char>(m));
vector<vector<int>> below(n, vector<int>(m));
for(auto &r:mat) for(auto &e:r) cin>>e;
for(int j = 0; j < m; j++) for(int i = n-1; i >= 0; i--)
below[i][j]=below[min(n-1, i+1)][j]+(mat[i][j]=='I');
ll ans=0;
for(int i = 0; i < n; i++){
int cur=0;
for(int j = m-1; j >= 0; j--) ans+=(mat[i][j]=='J')*(cur+=(mat[i][j]=='O'))*below[i][j];
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |