#include<bits/stdc++.h>
using namespace std;
const int N = 3087;
char g[N][N];
int si[N][N];
int n,m;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; ++i)
cin >> g[i];
long long ans = 0;
for (int i = n-1; i >= 0; --i) {
int so = 0;
for (int j = m-1; j >= 0; --j) {
so += g[i][j] == 'O';
si[i][j] = (g[i][j] == 'I') + si[i+1][j];
ans += (g[i][j] == 'J') * so * 1ll * si[i][j];
}
}
cout << ans << endl;
}
# |
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 |
1144 KB |
Output is correct |
6 |
Correct |
3 ms |
1016 KB |
Output is correct |
7 |
Correct |
2 ms |
1016 KB |
Output is correct |
8 |
Correct |
3 ms |
1144 KB |
Output is correct |
9 |
Correct |
3 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
1020 KB |
Output is correct |
11 |
Correct |
3 ms |
1144 KB |
Output is correct |
12 |
Correct |
3 ms |
1144 KB |
Output is correct |
13 |
Correct |
3 ms |
1016 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 |
1144 KB |
Output is correct |
6 |
Correct |
3 ms |
1016 KB |
Output is correct |
7 |
Correct |
2 ms |
1016 KB |
Output is correct |
8 |
Correct |
3 ms |
1144 KB |
Output is correct |
9 |
Correct |
3 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
1020 KB |
Output is correct |
11 |
Correct |
3 ms |
1144 KB |
Output is correct |
12 |
Correct |
3 ms |
1144 KB |
Output is correct |
13 |
Correct |
3 ms |
1016 KB |
Output is correct |
14 |
Correct |
6 ms |
4728 KB |
Output is correct |
15 |
Correct |
4 ms |
3324 KB |
Output is correct |
16 |
Correct |
4 ms |
2808 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
7 ms |
5112 KB |
Output is correct |
19 |
Correct |
7 ms |
5112 KB |
Output is correct |
20 |
Correct |
7 ms |
4984 KB |
Output is correct |
21 |
Correct |
7 ms |
5112 KB |
Output is correct |
22 |
Correct |
7 ms |
5112 KB |
Output is correct |
23 |
Correct |
7 ms |
4984 KB |
Output is correct |
24 |
Correct |
7 ms |
5112 KB |
Output is correct |
25 |
Correct |
6 ms |
5112 KB |
Output is correct |
26 |
Correct |
7 ms |
4984 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 |
1144 KB |
Output is correct |
6 |
Correct |
3 ms |
1016 KB |
Output is correct |
7 |
Correct |
2 ms |
1016 KB |
Output is correct |
8 |
Correct |
3 ms |
1144 KB |
Output is correct |
9 |
Correct |
3 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
1020 KB |
Output is correct |
11 |
Correct |
3 ms |
1144 KB |
Output is correct |
12 |
Correct |
3 ms |
1144 KB |
Output is correct |
13 |
Correct |
3 ms |
1016 KB |
Output is correct |
14 |
Correct |
6 ms |
4728 KB |
Output is correct |
15 |
Correct |
4 ms |
3324 KB |
Output is correct |
16 |
Correct |
4 ms |
2808 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
7 ms |
5112 KB |
Output is correct |
19 |
Correct |
7 ms |
5112 KB |
Output is correct |
20 |
Correct |
7 ms |
4984 KB |
Output is correct |
21 |
Correct |
7 ms |
5112 KB |
Output is correct |
22 |
Correct |
7 ms |
5112 KB |
Output is correct |
23 |
Correct |
7 ms |
4984 KB |
Output is correct |
24 |
Correct |
7 ms |
5112 KB |
Output is correct |
25 |
Correct |
6 ms |
5112 KB |
Output is correct |
26 |
Correct |
7 ms |
4984 KB |
Output is correct |
27 |
Correct |
72 ms |
54008 KB |
Output is correct |
28 |
Correct |
16 ms |
16888 KB |
Output is correct |
29 |
Correct |
8 ms |
4856 KB |
Output is correct |
30 |
Correct |
2 ms |
504 KB |
Output is correct |
31 |
Correct |
57 ms |
44280 KB |
Output is correct |
32 |
Correct |
76 ms |
54348 KB |
Output is correct |
33 |
Correct |
74 ms |
54264 KB |
Output is correct |
34 |
Correct |
66 ms |
51324 KB |
Output is correct |
35 |
Correct |
84 ms |
54364 KB |
Output is correct |
36 |
Correct |
72 ms |
54260 KB |
Output is correct |
37 |
Correct |
73 ms |
54524 KB |
Output is correct |
38 |
Correct |
59 ms |
44200 KB |
Output is correct |
39 |
Correct |
56 ms |
44024 KB |
Output is correct |