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 fi first
#define se second
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<vector<char>> c(n + 1, vector<char>(m + 1));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> c[i][j];
}
}
int ans = 0;
vector<int> ci(m + 1);
for (int i = n; i >= 1; i--) {
int co = 0;
for (int j = m; j >= 1; j--) {
if (c[i][j] == 'J') {
ans += ci[j] * co;
}
if (c[i][j] == 'O') {
co += 1;
}
if (c[i][j] == 'I') {
ci[j] += 1;
}
}
}
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... |