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
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define pb push_back
void solve() {
int n,m;
cin>>n>>m;
char grid[n][m];
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
cin>>grid[i][j];
}
}
int ans = 0;
int a[n][m],b[n][m];
for(int i = n - 1;i >= 0;i--){
for(int j = m - 1;j >= 0;j--){
a[i][j] = (j == m - 1?0:a[i][j + 1]) + (grid[i][j] == 'O');
b[i][j] = (i == n - 1?0:b[i + 1][j]) + (grid[i][j] == 'I');
if(grid[i][j] == 'J')ans+=a[i][j]*b[i][j];
}
}
cout<<ans;
return;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int tt=1; //cin>>tt;
while(tt--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |