#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL n, m, br, lo[3009][3009], li[3009][3009];
char zad[3009][3009];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m;
for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin >> zad[i][j];
for(int i=0; i<n; i++){
br = 0;
for(int j=m-1; j >= 0; j--){
if (zad[i][j] == 'O') br++;
lo[i][j] = br;
}
}
for(int j=0; j<m; j++){
br = 0;
for(int i=n-1; i >= 0; i--){
if (zad[i][j] == 'I') br++;
li[i][j] = br;
}
}
br = 0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if (zad[i][j] == 'J') br += lo[i][j] * li[i][j];
}
}
cout << br; return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
352 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1480 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
352 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1480 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1484 KB |
Output is correct |
14 |
Correct |
7 ms |
8916 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
5332 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
9 ms |
9896 KB |
Output is correct |
19 |
Correct |
9 ms |
9792 KB |
Output is correct |
20 |
Correct |
8 ms |
9684 KB |
Output is correct |
21 |
Correct |
8 ms |
9960 KB |
Output is correct |
22 |
Correct |
7 ms |
9788 KB |
Output is correct |
23 |
Correct |
6 ms |
9684 KB |
Output is correct |
24 |
Correct |
8 ms |
9936 KB |
Output is correct |
25 |
Correct |
6 ms |
9812 KB |
Output is correct |
26 |
Correct |
7 ms |
9704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
352 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1480 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1484 KB |
Output is correct |
14 |
Correct |
7 ms |
8916 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
5332 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
9 ms |
9896 KB |
Output is correct |
19 |
Correct |
9 ms |
9792 KB |
Output is correct |
20 |
Correct |
8 ms |
9684 KB |
Output is correct |
21 |
Correct |
8 ms |
9960 KB |
Output is correct |
22 |
Correct |
7 ms |
9788 KB |
Output is correct |
23 |
Correct |
6 ms |
9684 KB |
Output is correct |
24 |
Correct |
8 ms |
9936 KB |
Output is correct |
25 |
Correct |
6 ms |
9812 KB |
Output is correct |
26 |
Correct |
7 ms |
9704 KB |
Output is correct |
27 |
Correct |
301 ms |
158776 KB |
Output is correct |
28 |
Correct |
10 ms |
26320 KB |
Output is correct |
29 |
Correct |
13 ms |
13908 KB |
Output is correct |
30 |
Correct |
1 ms |
724 KB |
Output is correct |
31 |
Correct |
225 ms |
131448 KB |
Output is correct |
32 |
Correct |
328 ms |
159116 KB |
Output is correct |
33 |
Correct |
320 ms |
158704 KB |
Output is correct |
34 |
Correct |
270 ms |
152544 KB |
Output is correct |
35 |
Correct |
285 ms |
159304 KB |
Output is correct |
36 |
Correct |
287 ms |
158732 KB |
Output is correct |
37 |
Correct |
306 ms |
159180 KB |
Output is correct |
38 |
Correct |
214 ms |
130788 KB |
Output is correct |
39 |
Correct |
195 ms |
130924 KB |
Output is correct |