#include <bits/stdc++.h>
using namespace std;
const int DIM = 3005;
char mat[DIM][DIM];
int psm1[DIM][DIM], psm2[DIM][DIM];
int main(void) {
#ifdef HOME
freopen("brave.in", "r", stdin);
freopen("brave.out", "w", stdout);
#endif
int n, m; cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> (mat[i] + 1); }
long long ans = 0;
for (int i = n; i >= 1; --i) {
for (int j = m; j >= 1; --j) {
psm1[i][j] = psm1[i][j + 1] + (mat[i][j] == 'O');
psm2[i][j] = psm2[i + 1][j] + (mat[i][j] == 'I');
if (mat[i][j] == 'J') {
ans += psm1[i][j] * psm2[i][j]; } } }
cout << ans << endl;
return 0; }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
356 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1536 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
356 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1536 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
18 ms |
7352 KB |
Output is correct |
15 |
Correct |
7 ms |
4992 KB |
Output is correct |
16 |
Correct |
12 ms |
4224 KB |
Output is correct |
17 |
Correct |
3 ms |
428 KB |
Output is correct |
18 |
Correct |
23 ms |
7936 KB |
Output is correct |
19 |
Correct |
18 ms |
7800 KB |
Output is correct |
20 |
Correct |
16 ms |
7808 KB |
Output is correct |
21 |
Correct |
21 ms |
7936 KB |
Output is correct |
22 |
Correct |
16 ms |
7808 KB |
Output is correct |
23 |
Correct |
20 ms |
7800 KB |
Output is correct |
24 |
Correct |
23 ms |
7928 KB |
Output is correct |
25 |
Correct |
16 ms |
7844 KB |
Output is correct |
26 |
Correct |
18 ms |
7808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
356 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1536 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
18 ms |
7352 KB |
Output is correct |
15 |
Correct |
7 ms |
4992 KB |
Output is correct |
16 |
Correct |
12 ms |
4224 KB |
Output is correct |
17 |
Correct |
3 ms |
428 KB |
Output is correct |
18 |
Correct |
23 ms |
7936 KB |
Output is correct |
19 |
Correct |
18 ms |
7800 KB |
Output is correct |
20 |
Correct |
16 ms |
7808 KB |
Output is correct |
21 |
Correct |
21 ms |
7936 KB |
Output is correct |
22 |
Correct |
16 ms |
7808 KB |
Output is correct |
23 |
Correct |
20 ms |
7800 KB |
Output is correct |
24 |
Correct |
23 ms |
7928 KB |
Output is correct |
25 |
Correct |
16 ms |
7844 KB |
Output is correct |
26 |
Correct |
18 ms |
7808 KB |
Output is correct |
27 |
Correct |
371 ms |
87896 KB |
Output is correct |
28 |
Correct |
26 ms |
25984 KB |
Output is correct |
29 |
Correct |
30 ms |
7672 KB |
Output is correct |
30 |
Correct |
4 ms |
640 KB |
Output is correct |
31 |
Correct |
344 ms |
72568 KB |
Output is correct |
32 |
Correct |
397 ms |
88440 KB |
Output is correct |
33 |
Correct |
373 ms |
88264 KB |
Output is correct |
34 |
Correct |
355 ms |
84088 KB |
Output is correct |
35 |
Correct |
379 ms |
88440 KB |
Output is correct |
36 |
Correct |
473 ms |
88312 KB |
Output is correct |
37 |
Correct |
415 ms |
88368 KB |
Output is correct |
38 |
Correct |
265 ms |
72388 KB |
Output is correct |
39 |
Correct |
267 ms |
72312 KB |
Output is correct |