#include <iostream>
using namespace std;
long long n,m,ans;
string s[3005];
long long dpR[3005][3005];
long long dpD[3005][3005];
int main()
{
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>s[i];
for(int i=n-1;i>=0;i--)
for(int j=m-1;j>=0;j--)
{
dpR[i][j]=dpR[i][j+1] + (s[i][j] == 'O');
dpD[i][j]=dpD[i+1][j] + (s[i][j] == 'I');
if(s[i][j] == 'J')
ans += dpR[i][j] * dpD[i][j];
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
1 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
1 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1228 KB |
Output is correct |
14 |
Correct |
12 ms |
7780 KB |
Output is correct |
15 |
Correct |
2 ms |
3788 KB |
Output is correct |
16 |
Correct |
6 ms |
4812 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
11 ms |
8984 KB |
Output is correct |
19 |
Correct |
9 ms |
8640 KB |
Output is correct |
20 |
Correct |
9 ms |
8844 KB |
Output is correct |
21 |
Correct |
10 ms |
9036 KB |
Output is correct |
22 |
Correct |
9 ms |
8604 KB |
Output is correct |
23 |
Correct |
9 ms |
8852 KB |
Output is correct |
24 |
Correct |
12 ms |
9028 KB |
Output is correct |
25 |
Correct |
9 ms |
8652 KB |
Output is correct |
26 |
Correct |
9 ms |
8780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
1 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1228 KB |
Output is correct |
14 |
Correct |
12 ms |
7780 KB |
Output is correct |
15 |
Correct |
2 ms |
3788 KB |
Output is correct |
16 |
Correct |
6 ms |
4812 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
11 ms |
8984 KB |
Output is correct |
19 |
Correct |
9 ms |
8640 KB |
Output is correct |
20 |
Correct |
9 ms |
8844 KB |
Output is correct |
21 |
Correct |
10 ms |
9036 KB |
Output is correct |
22 |
Correct |
9 ms |
8604 KB |
Output is correct |
23 |
Correct |
9 ms |
8852 KB |
Output is correct |
24 |
Correct |
12 ms |
9028 KB |
Output is correct |
25 |
Correct |
9 ms |
8652 KB |
Output is correct |
26 |
Correct |
9 ms |
8780 KB |
Output is correct |
27 |
Correct |
258 ms |
161116 KB |
Output is correct |
28 |
Correct |
10 ms |
19540 KB |
Output is correct |
29 |
Correct |
20 ms |
14148 KB |
Output is correct |
30 |
Correct |
2 ms |
844 KB |
Output is correct |
31 |
Correct |
195 ms |
133428 KB |
Output is correct |
32 |
Correct |
251 ms |
161492 KB |
Output is correct |
33 |
Correct |
253 ms |
161068 KB |
Output is correct |
34 |
Correct |
260 ms |
154776 KB |
Output is correct |
35 |
Correct |
256 ms |
161548 KB |
Output is correct |
36 |
Correct |
256 ms |
161068 KB |
Output is correct |
37 |
Correct |
278 ms |
161560 KB |
Output is correct |
38 |
Correct |
204 ms |
132932 KB |
Output is correct |
39 |
Correct |
186 ms |
132972 KB |
Output is correct |