//testing
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 3000 + 10;
int H,W;
vector<vector<int>> grid(MAX,vector<int>(MAX));
int ups1[MAX][MAX], ups2[MAX][MAX], lefts1[MAX][MAX], lefts2[MAX][MAX];
int main() {
cin >> H >> W;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
char c; cin >> c;
if (c == 'J') grid[i][j] = 0;
else if (c == 'O') grid[i][j] = 1;
else grid[i][j] = 2;
}
}
ll c = 0;
for (int i = H-1; i >= 0; i--) {
for (int j = W-1; j >= 0; j--) {
ups1[i][j] = ups1[i+1][j];
ups2[i][j] = ups2[i+1][j];
lefts1[i][j] = lefts1[i][j+1];
lefts2[i][j] = lefts2[i][j+1];
ll ways = 0;
if (grid[i][j] == 0) {
ways += (ll)ups1[i][j]*lefts2[i][j];
ways += (ll)ups2[i][j]*lefts1[i][j];
}
else if (grid[i][j] == 1) {
ups1[i][j]++;
lefts1[i][j]++;
}
else if (grid[i][j] == 2) {
ups2[i][j]++;
lefts2[i][j]++;
}
c += ways;
}
}
cout << c << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
35960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
35960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
35960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |