#include<bits/stdc++.h>
using namespace std;
int h,w;
string grid[3005];
long long qs1[3005][3005],qs2[3005][3005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> h >> w;
for(int i=1;i<=h;i++){
string s;
cin >> s;
s=" "+s;
grid[i]=s;
}
memset(qs1,0,sizeof(qs1));
memset(qs2,0,sizeof(qs2));
for(int i=1;i<=h;i++){
for(int j=w;j>=1;j--){
qs1[i][j]=qs1[i][j+1]+(grid[i][j]=='O');
}
}
for(int i=h;i>=1;i--){
for(int j=1;j<=w;j++){
qs2[i][j]=qs2[i+1][j]+(grid[i][j]=='I');
}
}
long long ans=0;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
if(grid[i][j]=='J'){
ans+=qs1[i][j]*qs2[i][j];
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
141648 KB |
Output is correct |
2 |
Correct |
57 ms |
141644 KB |
Output is correct |
3 |
Correct |
54 ms |
141736 KB |
Output is correct |
4 |
Correct |
51 ms |
141644 KB |
Output is correct |
5 |
Correct |
54 ms |
141752 KB |
Output is correct |
6 |
Correct |
52 ms |
141732 KB |
Output is correct |
7 |
Correct |
52 ms |
141684 KB |
Output is correct |
8 |
Correct |
61 ms |
141748 KB |
Output is correct |
9 |
Correct |
61 ms |
141672 KB |
Output is correct |
10 |
Correct |
52 ms |
141692 KB |
Output is correct |
11 |
Correct |
53 ms |
141696 KB |
Output is correct |
12 |
Correct |
56 ms |
141720 KB |
Output is correct |
13 |
Correct |
51 ms |
141748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
141648 KB |
Output is correct |
2 |
Correct |
57 ms |
141644 KB |
Output is correct |
3 |
Correct |
54 ms |
141736 KB |
Output is correct |
4 |
Correct |
51 ms |
141644 KB |
Output is correct |
5 |
Correct |
54 ms |
141752 KB |
Output is correct |
6 |
Correct |
52 ms |
141732 KB |
Output is correct |
7 |
Correct |
52 ms |
141684 KB |
Output is correct |
8 |
Correct |
61 ms |
141748 KB |
Output is correct |
9 |
Correct |
61 ms |
141672 KB |
Output is correct |
10 |
Correct |
52 ms |
141692 KB |
Output is correct |
11 |
Correct |
53 ms |
141696 KB |
Output is correct |
12 |
Correct |
56 ms |
141720 KB |
Output is correct |
13 |
Correct |
51 ms |
141748 KB |
Output is correct |
14 |
Correct |
55 ms |
141920 KB |
Output is correct |
15 |
Correct |
57 ms |
141636 KB |
Output is correct |
16 |
Correct |
59 ms |
141872 KB |
Output is correct |
17 |
Correct |
52 ms |
141728 KB |
Output is correct |
18 |
Correct |
53 ms |
142028 KB |
Output is correct |
19 |
Correct |
58 ms |
141908 KB |
Output is correct |
20 |
Correct |
60 ms |
142028 KB |
Output is correct |
21 |
Correct |
67 ms |
142232 KB |
Output is correct |
22 |
Correct |
66 ms |
142228 KB |
Output is correct |
23 |
Correct |
53 ms |
142260 KB |
Output is correct |
24 |
Correct |
55 ms |
142204 KB |
Output is correct |
25 |
Correct |
55 ms |
142164 KB |
Output is correct |
26 |
Correct |
54 ms |
142160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
141648 KB |
Output is correct |
2 |
Correct |
57 ms |
141644 KB |
Output is correct |
3 |
Correct |
54 ms |
141736 KB |
Output is correct |
4 |
Correct |
51 ms |
141644 KB |
Output is correct |
5 |
Correct |
54 ms |
141752 KB |
Output is correct |
6 |
Correct |
52 ms |
141732 KB |
Output is correct |
7 |
Correct |
52 ms |
141684 KB |
Output is correct |
8 |
Correct |
61 ms |
141748 KB |
Output is correct |
9 |
Correct |
61 ms |
141672 KB |
Output is correct |
10 |
Correct |
52 ms |
141692 KB |
Output is correct |
11 |
Correct |
53 ms |
141696 KB |
Output is correct |
12 |
Correct |
56 ms |
141720 KB |
Output is correct |
13 |
Correct |
51 ms |
141748 KB |
Output is correct |
14 |
Correct |
55 ms |
141920 KB |
Output is correct |
15 |
Correct |
57 ms |
141636 KB |
Output is correct |
16 |
Correct |
59 ms |
141872 KB |
Output is correct |
17 |
Correct |
52 ms |
141728 KB |
Output is correct |
18 |
Correct |
53 ms |
142028 KB |
Output is correct |
19 |
Correct |
58 ms |
141908 KB |
Output is correct |
20 |
Correct |
60 ms |
142028 KB |
Output is correct |
21 |
Correct |
67 ms |
142232 KB |
Output is correct |
22 |
Correct |
66 ms |
142228 KB |
Output is correct |
23 |
Correct |
53 ms |
142260 KB |
Output is correct |
24 |
Correct |
55 ms |
142204 KB |
Output is correct |
25 |
Correct |
55 ms |
142164 KB |
Output is correct |
26 |
Correct |
54 ms |
142160 KB |
Output is correct |
27 |
Correct |
153 ms |
158484 KB |
Output is correct |
28 |
Correct |
56 ms |
141744 KB |
Output is correct |
29 |
Correct |
56 ms |
143000 KB |
Output is correct |
30 |
Correct |
55 ms |
141772 KB |
Output is correct |
31 |
Correct |
129 ms |
153984 KB |
Output is correct |
32 |
Correct |
127 ms |
159228 KB |
Output is correct |
33 |
Correct |
122 ms |
159412 KB |
Output is correct |
34 |
Correct |
136 ms |
155980 KB |
Output is correct |
35 |
Correct |
123 ms |
159260 KB |
Output is correct |
36 |
Correct |
112 ms |
159420 KB |
Output is correct |
37 |
Correct |
147 ms |
159384 KB |
Output is correct |
38 |
Correct |
112 ms |
154008 KB |
Output is correct |
39 |
Correct |
106 ms |
154004 KB |
Output is correct |