#include <bits/stdc++.h>
using namespace std;
long long n, m, d[3003][3003][3], fp;
char a;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
cin >> a;
if(a == 'J') d[i][j][0] = 1;
else if(a == 'O') d[i][j][1] = 1;
else d[i][j][2] = 1;
}
}
for(int i = n; i; --i) {
for(int j = m; j; --j) {
d[i][j][1] += d[i][j + 1][1];
d[i][j][2] += d[i + 1][j][2];
}
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
if(d[i][j][0]) {
fp += d[i][j][1] * d[i][j][2];
}
}
}
cout << fp << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1016 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
888 KB |
Output is correct |
8 |
Correct |
3 ms |
1016 KB |
Output is correct |
9 |
Correct |
3 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
1016 KB |
Output is correct |
12 |
Correct |
3 ms |
1016 KB |
Output is correct |
13 |
Correct |
3 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1016 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
888 KB |
Output is correct |
8 |
Correct |
3 ms |
1016 KB |
Output is correct |
9 |
Correct |
3 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
1016 KB |
Output is correct |
12 |
Correct |
3 ms |
1016 KB |
Output is correct |
13 |
Correct |
3 ms |
888 KB |
Output is correct |
14 |
Correct |
15 ms |
6904 KB |
Output is correct |
15 |
Correct |
4 ms |
2300 KB |
Output is correct |
16 |
Correct |
8 ms |
4472 KB |
Output is correct |
17 |
Correct |
2 ms |
508 KB |
Output is correct |
18 |
Correct |
17 ms |
8312 KB |
Output is correct |
19 |
Correct |
14 ms |
8056 KB |
Output is correct |
20 |
Correct |
14 ms |
8184 KB |
Output is correct |
21 |
Correct |
17 ms |
8440 KB |
Output is correct |
22 |
Correct |
13 ms |
8184 KB |
Output is correct |
23 |
Correct |
14 ms |
8312 KB |
Output is correct |
24 |
Correct |
18 ms |
8440 KB |
Output is correct |
25 |
Correct |
13 ms |
8184 KB |
Output is correct |
26 |
Correct |
13 ms |
8312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1016 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
888 KB |
Output is correct |
8 |
Correct |
3 ms |
1016 KB |
Output is correct |
9 |
Correct |
3 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
1016 KB |
Output is correct |
12 |
Correct |
3 ms |
1016 KB |
Output is correct |
13 |
Correct |
3 ms |
888 KB |
Output is correct |
14 |
Correct |
15 ms |
6904 KB |
Output is correct |
15 |
Correct |
4 ms |
2300 KB |
Output is correct |
16 |
Correct |
8 ms |
4472 KB |
Output is correct |
17 |
Correct |
2 ms |
508 KB |
Output is correct |
18 |
Correct |
17 ms |
8312 KB |
Output is correct |
19 |
Correct |
14 ms |
8056 KB |
Output is correct |
20 |
Correct |
14 ms |
8184 KB |
Output is correct |
21 |
Correct |
17 ms |
8440 KB |
Output is correct |
22 |
Correct |
13 ms |
8184 KB |
Output is correct |
23 |
Correct |
14 ms |
8312 KB |
Output is correct |
24 |
Correct |
18 ms |
8440 KB |
Output is correct |
25 |
Correct |
13 ms |
8184 KB |
Output is correct |
26 |
Correct |
13 ms |
8312 KB |
Output is correct |
27 |
Correct |
547 ms |
212116 KB |
Output is correct |
28 |
Correct |
10 ms |
10588 KB |
Output is correct |
29 |
Correct |
28 ms |
17272 KB |
Output is correct |
30 |
Correct |
3 ms |
1016 KB |
Output is correct |
31 |
Correct |
343 ms |
163396 KB |
Output is correct |
32 |
Correct |
383 ms |
220700 KB |
Output is correct |
33 |
Correct |
357 ms |
220044 KB |
Output is correct |
34 |
Correct |
403 ms |
189368 KB |
Output is correct |
35 |
Correct |
392 ms |
220788 KB |
Output is correct |
36 |
Correct |
356 ms |
219932 KB |
Output is correct |
37 |
Correct |
518 ms |
220792 KB |
Output is correct |
38 |
Correct |
270 ms |
162060 KB |
Output is correct |
39 |
Correct |
255 ms |
162660 KB |
Output is correct |