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;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M;
cin >> N >> M;
vector<string> S(N);
for (auto &v : S) {
cin >> v;
}
vector row(N, vector<int>(M + 1)), col(M, vector<int>(N + 1));
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
row[i][j + 1] = row[i][j] + int(S[i][j] == 'O');
}
}
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
col[i][j + 1] = col[i][j] + int(S[j][i] == 'I');
}
}
long long ans = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (S[i][j] == 'J') {
ans += (row[i][M] - row[i][j]) * (col[j][N] - col[j][i]);
}
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |