#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m; cin >> n >> m;
vector<str> v(n);
for(str &s: v) cin >> s;
vector<ll> ingots(m, 0LL);
ll ans = 0;
for(int i = n-1; i >= 0; i--){
ll orbs = 0;
for(int j = m-1; j >= 0; j--){
if(v[i][j] == 'J') ans+=orbs*ingots[j];
if(v[i][j] == 'O') orbs++;
if(v[i][j] == 'I') ingots[j]++;
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
2 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
1 ms |
460 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
3 ms |
800 KB |
Output is correct |
19 |
Correct |
2 ms |
796 KB |
Output is correct |
20 |
Correct |
2 ms |
696 KB |
Output is correct |
21 |
Correct |
3 ms |
716 KB |
Output is correct |
22 |
Correct |
1 ms |
680 KB |
Output is correct |
23 |
Correct |
1 ms |
812 KB |
Output is correct |
24 |
Correct |
4 ms |
716 KB |
Output is correct |
25 |
Correct |
2 ms |
708 KB |
Output is correct |
26 |
Correct |
1 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
2 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
1 ms |
460 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
3 ms |
800 KB |
Output is correct |
19 |
Correct |
2 ms |
796 KB |
Output is correct |
20 |
Correct |
2 ms |
696 KB |
Output is correct |
21 |
Correct |
3 ms |
716 KB |
Output is correct |
22 |
Correct |
1 ms |
680 KB |
Output is correct |
23 |
Correct |
1 ms |
812 KB |
Output is correct |
24 |
Correct |
4 ms |
716 KB |
Output is correct |
25 |
Correct |
2 ms |
708 KB |
Output is correct |
26 |
Correct |
1 ms |
692 KB |
Output is correct |
27 |
Correct |
78 ms |
17732 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
3 ms |
1600 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
55 ms |
13252 KB |
Output is correct |
32 |
Correct |
39 ms |
18760 KB |
Output is correct |
33 |
Correct |
28 ms |
18828 KB |
Output is correct |
34 |
Correct |
62 ms |
15148 KB |
Output is correct |
35 |
Correct |
38 ms |
18900 KB |
Output is correct |
36 |
Correct |
28 ms |
18776 KB |
Output is correct |
37 |
Correct |
83 ms |
18884 KB |
Output is correct |
38 |
Correct |
26 ms |
13096 KB |
Output is correct |
39 |
Correct |
19 ms |
13124 KB |
Output is correct |