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 i64 long long
#define int long long
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
void Solve(void) {
int N, M; cin >> N >> M;
vector<vector<char>> g(N + 2, vector<char> (M + 2));
vector<vector<int>> prefI(N + 2, vector<int> (M + 2, 0));
vector<vector<int>> prefO(N + 2, vector<int> (M + 2, 0));
for (int i = 1; i <= N; i ++) {
for (int j = 1; j <= M; j ++) {
cin >> g[i][j];
prefO[i][j] = prefO[i][j - 1] + (g[i][j] == 'O');
prefI[i][j] = prefI[i - 1][j] + (g[i][j] == 'I');
}
}
i64 ans = 0;
for (int i = 1; i <= N; i ++) {
for (int j = 1; j <= M; j ++) {
if (g[i][j] == 'J') {
ans = ans + 1LL * (prefO[i][M] - prefO[i][j]) * (prefI[N][j] - prefI[i][j]);
}
}
}
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int Tests = 1; // cin >> Tests;
while (Tests --) {
Solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |