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 <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <deque>
using namespace std;
#define ll long long
ll n, m, ans;
char matrix[3005][3005];
int main() {
cin >> n >> m;
int preRight[3005][3005] = {0}, preDown[3005][3005] = {0};
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> matrix[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
preRight[i][j] = preRight[i][j - 1];
if (matrix[i][j] == 'O') {
preRight[i][j]++;
}
//cout << preRight[i][j] << " " << i << " | " << j << "\n";
}
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++) {
preDown[i][j] = preDown[i - 1][j];
if (matrix[i][j] == 'I') {
preDown[i][j]++;
}
//cout << preDown[i][j] << " " << i << " | " << j << "\n";
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (matrix[i][j] == 'J') {
ans += (preRight[i][m] - preRight[i][j]) * (preDown[n][j] - preDown[i][j]);
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |