#include <iostream>
using namespace std;
int h, w;
char S[3010][3010];
int O[3010][3010], I[3010][3010];
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>h>>w;
for(int i=0; i<h; i++) cin>>S[i];
for(int i=0; i<h; i++) for(int j=w-1; j>=0; j--)
O[i][j] = O[i][j+1] + (S[i][j]=='O');
for(int j=0; j<w; j++) for(int i=h-1; i>=0; i--)
I[i][j] = I[i+1][j] + (S[i][j]=='I');
long long ans = 0;
for(int i=0; i<h; i++) for(int j=0; j<w; j++)
ans += 1LL*(S[i][j]=='J') * O[i][j] * I[i][j];
cout<<ans<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
432 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
432 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1536 KB |
Output is correct |
14 |
Correct |
11 ms |
7552 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
8 ms |
4352 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
11 ms |
8064 KB |
Output is correct |
19 |
Correct |
11 ms |
7988 KB |
Output is correct |
20 |
Correct |
11 ms |
7808 KB |
Output is correct |
21 |
Correct |
12 ms |
8064 KB |
Output is correct |
22 |
Correct |
12 ms |
7936 KB |
Output is correct |
23 |
Correct |
11 ms |
7908 KB |
Output is correct |
24 |
Correct |
11 ms |
8064 KB |
Output is correct |
25 |
Correct |
10 ms |
7936 KB |
Output is correct |
26 |
Correct |
11 ms |
7908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
432 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1536 KB |
Output is correct |
14 |
Correct |
11 ms |
7552 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
8 ms |
4352 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
11 ms |
8064 KB |
Output is correct |
19 |
Correct |
11 ms |
7988 KB |
Output is correct |
20 |
Correct |
11 ms |
7808 KB |
Output is correct |
21 |
Correct |
12 ms |
8064 KB |
Output is correct |
22 |
Correct |
12 ms |
7936 KB |
Output is correct |
23 |
Correct |
11 ms |
7908 KB |
Output is correct |
24 |
Correct |
11 ms |
8064 KB |
Output is correct |
25 |
Correct |
10 ms |
7936 KB |
Output is correct |
26 |
Correct |
11 ms |
7908 KB |
Output is correct |
27 |
Correct |
305 ms |
88240 KB |
Output is correct |
28 |
Correct |
25 ms |
26104 KB |
Output is correct |
29 |
Correct |
15 ms |
7808 KB |
Output is correct |
30 |
Correct |
0 ms |
640 KB |
Output is correct |
31 |
Correct |
218 ms |
72824 KB |
Output is correct |
32 |
Correct |
328 ms |
88696 KB |
Output is correct |
33 |
Correct |
313 ms |
88440 KB |
Output is correct |
34 |
Correct |
254 ms |
84336 KB |
Output is correct |
35 |
Correct |
304 ms |
88696 KB |
Output is correct |
36 |
Correct |
301 ms |
88440 KB |
Output is correct |
37 |
Correct |
295 ms |
88824 KB |
Output is correct |
38 |
Correct |
209 ms |
72700 KB |
Output is correct |
39 |
Correct |
221 ms |
72440 KB |
Output is correct |