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>
#define f first
#define s second
using namespace std;
#define int long long
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while(tt--) {
int n, m;
cin >> n >> m;
char a[n][m];
for(int i = 0;i < n;i++)
for(int j = 0;j < m;j++)
cin >> a[i][j];
vector<vector<int>> v(n, vector<int>(m));
for(int i = 0;i < n;i++) {
int p = 0;
for(int j = m - 1;j >= 0;j--) {
p += (a[i][j] == 'O');
if(a[i][j] == 'J')
v[i][j] = p;
}
}
for(int i = 0;i < m;i++) {
int p = 0;
for(int j = n - 1;j >= 0;j--) {
p += (a[j][i] == 'I');
if(a[j][i] == 'J')
v[j][i] *= p;
}
}
int ans = 0;
for(int i = 0;i < n;i++)
for(int j = 0;j < m;j++)
ans += v[i][j];
cout << ans;
}
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... |