#include<bits/stdc++.h>
using namespace std;
const int N = (int)3e3 + 5;
int n, m, cnt[2][N][N];
char s[N][N];
long long ans;
int main () {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) cin >> s[i][j];
}
for (int i = n; i > 0; --i) {
for (int j = m; j > 0; --j) {
cnt[0][i][j] = cnt[0][i][j + 1] + (s[i][j] == 'O');
cnt[1][i][j] = cnt[1][i + 1][j] + (s[i][j] == 'I');
if (s[i][j] == 'J') ans += cnt[0][i][j] * cnt[1][i][j];
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 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 |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1396 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1448 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 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 |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1396 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1448 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
12 ms |
7544 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
9 ms |
4344 KB |
Output is correct |
17 |
Correct |
3 ms |
504 KB |
Output is correct |
18 |
Correct |
14 ms |
8008 KB |
Output is correct |
19 |
Correct |
14 ms |
7928 KB |
Output is correct |
20 |
Correct |
12 ms |
7804 KB |
Output is correct |
21 |
Correct |
13 ms |
8056 KB |
Output is correct |
22 |
Correct |
13 ms |
7928 KB |
Output is correct |
23 |
Correct |
12 ms |
7928 KB |
Output is correct |
24 |
Correct |
14 ms |
7976 KB |
Output is correct |
25 |
Correct |
12 ms |
7972 KB |
Output is correct |
26 |
Correct |
12 ms |
7828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 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 |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1396 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1448 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
12 ms |
7544 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
9 ms |
4344 KB |
Output is correct |
17 |
Correct |
3 ms |
504 KB |
Output is correct |
18 |
Correct |
14 ms |
8008 KB |
Output is correct |
19 |
Correct |
14 ms |
7928 KB |
Output is correct |
20 |
Correct |
12 ms |
7804 KB |
Output is correct |
21 |
Correct |
13 ms |
8056 KB |
Output is correct |
22 |
Correct |
13 ms |
7928 KB |
Output is correct |
23 |
Correct |
12 ms |
7928 KB |
Output is correct |
24 |
Correct |
14 ms |
7976 KB |
Output is correct |
25 |
Correct |
12 ms |
7972 KB |
Output is correct |
26 |
Correct |
12 ms |
7828 KB |
Output is correct |
27 |
Correct |
227 ms |
88068 KB |
Output is correct |
28 |
Correct |
26 ms |
26104 KB |
Output is correct |
29 |
Correct |
19 ms |
7800 KB |
Output is correct |
30 |
Correct |
3 ms |
632 KB |
Output is correct |
31 |
Correct |
176 ms |
72696 KB |
Output is correct |
32 |
Correct |
216 ms |
88396 KB |
Output is correct |
33 |
Correct |
211 ms |
88184 KB |
Output is correct |
34 |
Correct |
201 ms |
84260 KB |
Output is correct |
35 |
Correct |
221 ms |
88460 KB |
Output is correct |
36 |
Correct |
211 ms |
88272 KB |
Output is correct |
37 |
Correct |
242 ms |
88524 KB |
Output is correct |
38 |
Correct |
159 ms |
72604 KB |
Output is correct |
39 |
Correct |
157 ms |
72340 KB |
Output is correct |