//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 ups2[MAX][MAX], lefts1[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--) {
ups2[i][j] = ups2[i+1][j];
lefts1[i][j] = lefts1[i][j+1];
ll ways = 0;
if (grid[i][j] == 0) {
ways += (ll)ups2[i][j]*lefts1[i][j];
}
else if (grid[i][j] == 1) {
lefts1[i][j]++;
}
else if (grid[i][j] == 2) {
ups2[i][j]++;
}
c += ways;
}
}
cout << c << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
35960 KB |
Output is correct |
2 |
Correct |
36 ms |
35840 KB |
Output is correct |
3 |
Correct |
38 ms |
35832 KB |
Output is correct |
4 |
Correct |
53 ms |
35960 KB |
Output is correct |
5 |
Correct |
33 ms |
36728 KB |
Output is correct |
6 |
Correct |
38 ms |
36728 KB |
Output is correct |
7 |
Correct |
34 ms |
36608 KB |
Output is correct |
8 |
Correct |
32 ms |
36680 KB |
Output is correct |
9 |
Correct |
31 ms |
36728 KB |
Output is correct |
10 |
Correct |
33 ms |
36600 KB |
Output is correct |
11 |
Correct |
33 ms |
36728 KB |
Output is correct |
12 |
Correct |
34 ms |
36728 KB |
Output is correct |
13 |
Correct |
32 ms |
36736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
35960 KB |
Output is correct |
2 |
Correct |
36 ms |
35840 KB |
Output is correct |
3 |
Correct |
38 ms |
35832 KB |
Output is correct |
4 |
Correct |
53 ms |
35960 KB |
Output is correct |
5 |
Correct |
33 ms |
36728 KB |
Output is correct |
6 |
Correct |
38 ms |
36728 KB |
Output is correct |
7 |
Correct |
34 ms |
36608 KB |
Output is correct |
8 |
Correct |
32 ms |
36680 KB |
Output is correct |
9 |
Correct |
31 ms |
36728 KB |
Output is correct |
10 |
Correct |
33 ms |
36600 KB |
Output is correct |
11 |
Correct |
33 ms |
36728 KB |
Output is correct |
12 |
Correct |
34 ms |
36728 KB |
Output is correct |
13 |
Correct |
32 ms |
36736 KB |
Output is correct |
14 |
Correct |
52 ms |
41436 KB |
Output is correct |
15 |
Correct |
38 ms |
39288 KB |
Output is correct |
16 |
Correct |
48 ms |
39032 KB |
Output is correct |
17 |
Correct |
32 ms |
35960 KB |
Output is correct |
18 |
Correct |
57 ms |
41848 KB |
Output is correct |
19 |
Correct |
54 ms |
41720 KB |
Output is correct |
20 |
Correct |
58 ms |
41720 KB |
Output is correct |
21 |
Correct |
55 ms |
41848 KB |
Output is correct |
22 |
Correct |
51 ms |
41720 KB |
Output is correct |
23 |
Correct |
87 ms |
41752 KB |
Output is correct |
24 |
Correct |
54 ms |
41848 KB |
Output is correct |
25 |
Correct |
61 ms |
41848 KB |
Output is correct |
26 |
Correct |
51 ms |
41720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
35960 KB |
Output is correct |
2 |
Correct |
36 ms |
35840 KB |
Output is correct |
3 |
Correct |
38 ms |
35832 KB |
Output is correct |
4 |
Correct |
53 ms |
35960 KB |
Output is correct |
5 |
Correct |
33 ms |
36728 KB |
Output is correct |
6 |
Correct |
38 ms |
36728 KB |
Output is correct |
7 |
Correct |
34 ms |
36608 KB |
Output is correct |
8 |
Correct |
32 ms |
36680 KB |
Output is correct |
9 |
Correct |
31 ms |
36728 KB |
Output is correct |
10 |
Correct |
33 ms |
36600 KB |
Output is correct |
11 |
Correct |
33 ms |
36728 KB |
Output is correct |
12 |
Correct |
34 ms |
36728 KB |
Output is correct |
13 |
Correct |
32 ms |
36736 KB |
Output is correct |
14 |
Correct |
52 ms |
41436 KB |
Output is correct |
15 |
Correct |
38 ms |
39288 KB |
Output is correct |
16 |
Correct |
48 ms |
39032 KB |
Output is correct |
17 |
Correct |
32 ms |
35960 KB |
Output is correct |
18 |
Correct |
57 ms |
41848 KB |
Output is correct |
19 |
Correct |
54 ms |
41720 KB |
Output is correct |
20 |
Correct |
58 ms |
41720 KB |
Output is correct |
21 |
Correct |
55 ms |
41848 KB |
Output is correct |
22 |
Correct |
51 ms |
41720 KB |
Output is correct |
23 |
Correct |
87 ms |
41752 KB |
Output is correct |
24 |
Correct |
54 ms |
41848 KB |
Output is correct |
25 |
Correct |
61 ms |
41848 KB |
Output is correct |
26 |
Correct |
51 ms |
41720 KB |
Output is correct |
27 |
Correct |
627 ms |
106616 KB |
Output is correct |
28 |
Correct |
50 ms |
54648 KB |
Output is correct |
29 |
Correct |
89 ms |
41976 KB |
Output is correct |
30 |
Correct |
32 ms |
36088 KB |
Output is correct |
31 |
Correct |
532 ms |
94836 KB |
Output is correct |
32 |
Correct |
603 ms |
106552 KB |
Output is correct |
33 |
Correct |
605 ms |
106336 KB |
Output is correct |
34 |
Correct |
541 ms |
104184 KB |
Output is correct |
35 |
Correct |
597 ms |
106616 KB |
Output is correct |
36 |
Correct |
583 ms |
106360 KB |
Output is correct |
37 |
Correct |
783 ms |
106744 KB |
Output is correct |
38 |
Correct |
477 ms |
94852 KB |
Output is correct |
39 |
Correct |
491 ms |
94584 KB |
Output is correct |