#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll ans = 0;
int h, w; cin >> h >> w;
vector<string> gri(h);
vector<vector<ll>> val(h, vector<ll> (w,0LL));
for(auto &x : gri)cin >> x;
for(int i = 0; i < h; ++i){
ll cn = 0;
for(int j = w-1; j >= 0; --j){
if(gri[i][j] == 'O')cn++;
if(gri[i][j] == 'J')val[i][j] = cn;
}
}
for(int j = 0; j < w; ++j){
ll cn = 0;
for(int i = h-1; i >= 0; --i){
if(gri[i][j] == 'I')cn++;
if(gri[i][j] == 'J')ans += cn*val[i][j];
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
16 ms |
2304 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
8 ms |
1664 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
18 ms |
3072 KB |
Output is correct |
19 |
Correct |
14 ms |
2688 KB |
Output is correct |
20 |
Correct |
15 ms |
2944 KB |
Output is correct |
21 |
Correct |
18 ms |
3072 KB |
Output is correct |
22 |
Correct |
14 ms |
2688 KB |
Output is correct |
23 |
Correct |
14 ms |
2944 KB |
Output is correct |
24 |
Correct |
18 ms |
3072 KB |
Output is correct |
25 |
Correct |
14 ms |
2688 KB |
Output is correct |
26 |
Correct |
15 ms |
3072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
16 ms |
2304 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
8 ms |
1664 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
18 ms |
3072 KB |
Output is correct |
19 |
Correct |
14 ms |
2688 KB |
Output is correct |
20 |
Correct |
15 ms |
2944 KB |
Output is correct |
21 |
Correct |
18 ms |
3072 KB |
Output is correct |
22 |
Correct |
14 ms |
2688 KB |
Output is correct |
23 |
Correct |
14 ms |
2944 KB |
Output is correct |
24 |
Correct |
18 ms |
3072 KB |
Output is correct |
25 |
Correct |
14 ms |
2688 KB |
Output is correct |
26 |
Correct |
15 ms |
3072 KB |
Output is correct |
27 |
Correct |
665 ms |
86708 KB |
Output is correct |
28 |
Correct |
3 ms |
640 KB |
Output is correct |
29 |
Correct |
36 ms |
7032 KB |
Output is correct |
30 |
Correct |
2 ms |
640 KB |
Output is correct |
31 |
Correct |
475 ms |
65144 KB |
Output is correct |
32 |
Correct |
564 ms |
90744 KB |
Output is correct |
33 |
Correct |
585 ms |
90872 KB |
Output is correct |
34 |
Correct |
553 ms |
75384 KB |
Output is correct |
35 |
Correct |
581 ms |
90532 KB |
Output is correct |
36 |
Correct |
582 ms |
90872 KB |
Output is correct |
37 |
Correct |
696 ms |
91256 KB |
Output is correct |
38 |
Correct |
403 ms |
64632 KB |
Output is correct |
39 |
Correct |
411 ms |
64760 KB |
Output is correct |