#include <bits/stdc++.h>
#define MAXN 3007
using namespace std;
char c[MAXN][MAXN];
long long l[MAXN][MAXN],d[MAXN][MAXN],sol;
int main()
{
int h,w; cin>>h>>w;
for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>c[i][j];
for(int i=h-1;i>=0;i--) for(int j=0;j<w;j++) l[i][j]=l[i+1][j]+(c[i][j]=='I'?1:0);
for(int j=w-1;j>=0;j--) for(int i=0;i<h;i++) d[i][j]=d[i][j+1]+(c[i][j]=='O'?1:0);
for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(c[i][j]=='J') sol+=l[i][j]*d[i][j];
cout<<sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1664 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1536 KB |
Output is correct |
8 |
Correct |
4 ms |
1664 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1664 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1536 KB |
Output is correct |
8 |
Correct |
4 ms |
1664 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 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 |
21 ms |
8952 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
14 ms |
5248 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
25 ms |
9968 KB |
Output is correct |
19 |
Correct |
27 ms |
9820 KB |
Output is correct |
20 |
Correct |
24 ms |
9728 KB |
Output is correct |
21 |
Correct |
30 ms |
9976 KB |
Output is correct |
22 |
Correct |
23 ms |
9720 KB |
Output is correct |
23 |
Correct |
25 ms |
9728 KB |
Output is correct |
24 |
Correct |
28 ms |
9976 KB |
Output is correct |
25 |
Correct |
24 ms |
9756 KB |
Output is correct |
26 |
Correct |
23 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1664 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1536 KB |
Output is correct |
8 |
Correct |
4 ms |
1664 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 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 |
21 ms |
8952 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
14 ms |
5248 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
25 ms |
9968 KB |
Output is correct |
19 |
Correct |
27 ms |
9820 KB |
Output is correct |
20 |
Correct |
24 ms |
9728 KB |
Output is correct |
21 |
Correct |
30 ms |
9976 KB |
Output is correct |
22 |
Correct |
23 ms |
9720 KB |
Output is correct |
23 |
Correct |
25 ms |
9728 KB |
Output is correct |
24 |
Correct |
28 ms |
9976 KB |
Output is correct |
25 |
Correct |
24 ms |
9756 KB |
Output is correct |
26 |
Correct |
23 ms |
9728 KB |
Output is correct |
27 |
Correct |
882 ms |
154368 KB |
Output is correct |
28 |
Correct |
25 ms |
26240 KB |
Output is correct |
29 |
Correct |
53 ms |
13904 KB |
Output is correct |
30 |
Correct |
3 ms |
768 KB |
Output is correct |
31 |
Correct |
623 ms |
128632 KB |
Output is correct |
32 |
Correct |
868 ms |
154104 KB |
Output is correct |
33 |
Correct |
888 ms |
153592 KB |
Output is correct |
34 |
Correct |
722 ms |
149396 KB |
Output is correct |
35 |
Execution timed out |
1022 ms |
154164 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |