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
int n, m, ans;
string matrix[3005];
int main() {
cin >> n >> m;
int preRight[3005][3005], preDown[3005][3005];
for (int i = 1; i <= n; i++) {
cin >> matrix[i];
}
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]++;
}
}
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= m; i++) {
preDown[i][j] = preDown[i][j - 1];
if (matrix[i][j] == 'I') {
preDown[i][j]++;
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (matrix[i][j] == 'P') {
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... |