#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
71060 KB |
Output is correct |
2 |
Incorrect |
31 ms |
70964 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
71060 KB |
Output is correct |
2 |
Incorrect |
31 ms |
70964 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
71060 KB |
Output is correct |
2 |
Incorrect |
31 ms |
70964 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |