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()
{
int n, m;
cin>>n>>m;
char a[n + 5][m + 5];
int s1[n + 5][m + 5] = {}, s2[n + 5][m + 5] = {};
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++) cin>>a[i][j];
}
for(int i=n; i>=1; i--)
{
for(int j=m; j>=1; j--)
{
s1[i][j] = s1[i][j + 1] + (a[i][j] == 'O');
s2[i][j] = s2[i + 1][j] + (a[i][j] == 'I');
}
}
int ans = 0;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
if (a[i][j] == 'J') ans += (s1[i][j + 1] * s2[i + 1][j]);
}
}
cout<<ans<<endl;
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... |