#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int h,w;
cin >> h >> w;
char a[h][w];
for(int i=0; i<h; ++i) {
for(int j=0; j<w; ++j) cin >> a[i][j];
}
int ans=0;
int cnt[w]; memset(cnt,0,sizeof(cnt));
for(int i=h-1; i>=0; --i) {
int curr=0;
for(int j=w-1; j>=0; --j) {
if(a[i][j]=='O') ++curr;
else if(a[i][j]=='I') {
++cnt[j];
}
else ans+=cnt[j]*curr;
}
}
cout << ans;
}
/*
6
4 1
1 5
10 3
9 1
4 2
5 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
5 ms |
616 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
460 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
6 ms |
724 KB |
Output is correct |
19 |
Correct |
5 ms |
852 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
5 ms |
724 KB |
Output is correct |
22 |
Correct |
4 ms |
716 KB |
Output is correct |
23 |
Correct |
4 ms |
796 KB |
Output is correct |
24 |
Correct |
6 ms |
724 KB |
Output is correct |
25 |
Correct |
4 ms |
716 KB |
Output is correct |
26 |
Correct |
4 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
5 ms |
616 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
460 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
6 ms |
724 KB |
Output is correct |
19 |
Correct |
5 ms |
852 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
5 ms |
724 KB |
Output is correct |
22 |
Correct |
4 ms |
716 KB |
Output is correct |
23 |
Correct |
4 ms |
796 KB |
Output is correct |
24 |
Correct |
6 ms |
724 KB |
Output is correct |
25 |
Correct |
4 ms |
716 KB |
Output is correct |
26 |
Correct |
4 ms |
716 KB |
Output is correct |
27 |
Correct |
155 ms |
16924 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
10 ms |
1492 KB |
Output is correct |
30 |
Correct |
1 ms |
460 KB |
Output is correct |
31 |
Correct |
119 ms |
12540 KB |
Output is correct |
32 |
Correct |
128 ms |
17736 KB |
Output is correct |
33 |
Correct |
116 ms |
17740 KB |
Output is correct |
34 |
Correct |
157 ms |
14540 KB |
Output is correct |
35 |
Correct |
125 ms |
17732 KB |
Output is correct |
36 |
Correct |
119 ms |
17764 KB |
Output is correct |
37 |
Correct |
158 ms |
17920 KB |
Output is correct |
38 |
Correct |
102 ms |
12388 KB |
Output is correct |
39 |
Correct |
83 ms |
12384 KB |
Output is correct |