/*** Author: Barish Namazov (toonewbie) ***/
#include <bits/stdc++.h>
using namespace std;
char A[3005][3005];
int si[3005][3005], so[3005][3005];
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> A[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = m; j >= 1; j--) {
so[i][j] = so[i][j + 1] + (A[i][j] == 'O');
}
}
for (int j = 1; j <= m; j++) {
for (int i = n; i >= 1; i--) {
si[i][j] = si[i + 1][j] + (A[i][j] == 'I');
}
}
long long res = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (A[i][j] == 'J') {
res += 1LL * so[i][j] * si[i][j];
}
}
}
cout << res << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
14 |
Correct |
29 ms |
7416 KB |
Output is correct |
15 |
Correct |
8 ms |
4992 KB |
Output is correct |
16 |
Correct |
15 ms |
4224 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
29 ms |
7928 KB |
Output is correct |
19 |
Correct |
26 ms |
7800 KB |
Output is correct |
20 |
Correct |
28 ms |
7800 KB |
Output is correct |
21 |
Correct |
30 ms |
7928 KB |
Output is correct |
22 |
Correct |
29 ms |
7780 KB |
Output is correct |
23 |
Correct |
31 ms |
7752 KB |
Output is correct |
24 |
Correct |
24 ms |
7976 KB |
Output is correct |
25 |
Correct |
25 ms |
7800 KB |
Output is correct |
26 |
Correct |
29 ms |
7808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
14 |
Correct |
29 ms |
7416 KB |
Output is correct |
15 |
Correct |
8 ms |
4992 KB |
Output is correct |
16 |
Correct |
15 ms |
4224 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
29 ms |
7928 KB |
Output is correct |
19 |
Correct |
26 ms |
7800 KB |
Output is correct |
20 |
Correct |
28 ms |
7800 KB |
Output is correct |
21 |
Correct |
30 ms |
7928 KB |
Output is correct |
22 |
Correct |
29 ms |
7780 KB |
Output is correct |
23 |
Correct |
31 ms |
7752 KB |
Output is correct |
24 |
Correct |
24 ms |
7976 KB |
Output is correct |
25 |
Correct |
25 ms |
7800 KB |
Output is correct |
26 |
Correct |
29 ms |
7808 KB |
Output is correct |
27 |
Correct |
879 ms |
83396 KB |
Output is correct |
28 |
Correct |
28 ms |
25976 KB |
Output is correct |
29 |
Correct |
54 ms |
7800 KB |
Output is correct |
30 |
Correct |
5 ms |
640 KB |
Output is correct |
31 |
Correct |
645 ms |
69956 KB |
Output is correct |
32 |
Correct |
892 ms |
83320 KB |
Output is correct |
33 |
Correct |
851 ms |
83124 KB |
Output is correct |
34 |
Correct |
853 ms |
80612 KB |
Output is correct |
35 |
Correct |
933 ms |
83364 KB |
Output is correct |
36 |
Correct |
788 ms |
83104 KB |
Output is correct |
37 |
Correct |
804 ms |
83448 KB |
Output is correct |
38 |
Correct |
544 ms |
70008 KB |
Output is correct |
39 |
Correct |
584 ms |
69904 KB |
Output is correct |