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 int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a, I = b; i <= I; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }
const int N = 3005;
char a[N][N];
int j_sum[N][N];
signed main() {
IO;
int n, m;
cin >> n >> m;
FOR(i, 1, n)
FOR(j, 1, m)
cin >> a[i][j];
for (int i = 1; i <= n; i++) {
int O_cnt = 0;
for (int j = m; j >= 1; j--) {
if (a[i][j] == 'O')
O_cnt += 1;
else if (a[i][j] == 'J')
j_sum[i][j] = O_cnt;
}
}
int ans = 0;
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++) {
j_sum[i][j] += j_sum[i - 1][j];
if (a[i][j] == 'I')
ans += j_sum[i][j];
}
}
cout << ans << "\n";
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... |