#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()
{
ios::sync_with_stdio(false);
cin.tie(0);
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 |
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 |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1636 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1664 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
3 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1664 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 |
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 |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1636 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1664 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
3 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1664 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1536 KB |
Output is correct |
14 |
Correct |
12 ms |
8832 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
8 ms |
5248 KB |
Output is correct |
17 |
Correct |
3 ms |
560 KB |
Output is correct |
18 |
Correct |
20 ms |
9728 KB |
Output is correct |
19 |
Correct |
27 ms |
9592 KB |
Output is correct |
20 |
Correct |
17 ms |
9600 KB |
Output is correct |
21 |
Correct |
16 ms |
9728 KB |
Output is correct |
22 |
Correct |
14 ms |
9600 KB |
Output is correct |
23 |
Correct |
14 ms |
9600 KB |
Output is correct |
24 |
Correct |
18 ms |
9884 KB |
Output is correct |
25 |
Correct |
14 ms |
9600 KB |
Output is correct |
26 |
Correct |
15 ms |
9600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1636 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1664 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
3 ms |
1536 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1664 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
3 ms |
1536 KB |
Output is correct |
14 |
Correct |
12 ms |
8832 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
8 ms |
5248 KB |
Output is correct |
17 |
Correct |
3 ms |
560 KB |
Output is correct |
18 |
Correct |
20 ms |
9728 KB |
Output is correct |
19 |
Correct |
27 ms |
9592 KB |
Output is correct |
20 |
Correct |
17 ms |
9600 KB |
Output is correct |
21 |
Correct |
16 ms |
9728 KB |
Output is correct |
22 |
Correct |
14 ms |
9600 KB |
Output is correct |
23 |
Correct |
14 ms |
9600 KB |
Output is correct |
24 |
Correct |
18 ms |
9884 KB |
Output is correct |
25 |
Correct |
14 ms |
9600 KB |
Output is correct |
26 |
Correct |
15 ms |
9600 KB |
Output is correct |
27 |
Correct |
467 ms |
150424 KB |
Output is correct |
28 |
Correct |
24 ms |
26368 KB |
Output is correct |
29 |
Correct |
28 ms |
13328 KB |
Output is correct |
30 |
Correct |
3 ms |
768 KB |
Output is correct |
31 |
Correct |
350 ms |
125432 KB |
Output is correct |
32 |
Correct |
456 ms |
150520 KB |
Output is correct |
33 |
Correct |
468 ms |
149884 KB |
Output is correct |
34 |
Correct |
419 ms |
145488 KB |
Output is correct |
35 |
Correct |
452 ms |
150392 KB |
Output is correct |
36 |
Correct |
453 ms |
153720 KB |
Output is correct |
37 |
Correct |
509 ms |
154232 KB |
Output is correct |
38 |
Correct |
347 ms |
127868 KB |
Output is correct |
39 |
Correct |
328 ms |
127992 KB |
Output is correct |