#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll H,W;
cin>>H>>W;
char arr[H][W];
ll row[H]; //number of unvisited orbs in row i
ll col[W]; //number of unvisited ingots in col j
memset(row,0,sizeof(row));
memset(col,0,sizeof(col));
for(ll i = 0;i < H;i++){
for(ll j = 0;j < W;j++){
cin>>arr[i][j];
if(arr[i][j] == 'O') row[i]++;
if(arr[i][j] == 'I') col[j]++;
}
}
ll sum = 0;
for(ll i = 0;i < H;i++){
for(ll j = 0;j < W;j++){
if(arr[i][j] == 'J'){
sum += row[i] * col[j];
}else if(arr[i][j] == 'O'){
row[i]--;
}else if(arr[i][j] == 'I'){
col[j]--;
}
}
}
cout<<sum<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
5 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
456 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
7 ms |
952 KB |
Output is correct |
19 |
Correct |
3 ms |
860 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
7 ms |
720 KB |
Output is correct |
22 |
Correct |
3 ms |
860 KB |
Output is correct |
23 |
Correct |
3 ms |
860 KB |
Output is correct |
24 |
Correct |
7 ms |
868 KB |
Output is correct |
25 |
Correct |
3 ms |
860 KB |
Output is correct |
26 |
Correct |
3 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
5 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
456 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
7 ms |
952 KB |
Output is correct |
19 |
Correct |
3 ms |
860 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
7 ms |
720 KB |
Output is correct |
22 |
Correct |
3 ms |
860 KB |
Output is correct |
23 |
Correct |
3 ms |
860 KB |
Output is correct |
24 |
Correct |
7 ms |
868 KB |
Output is correct |
25 |
Correct |
3 ms |
860 KB |
Output is correct |
26 |
Correct |
3 ms |
860 KB |
Output is correct |
27 |
Correct |
221 ms |
16980 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
7 ms |
1604 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
161 ms |
12580 KB |
Output is correct |
32 |
Correct |
119 ms |
17784 KB |
Output is correct |
33 |
Correct |
91 ms |
18000 KB |
Output is correct |
34 |
Correct |
189 ms |
14672 KB |
Output is correct |
35 |
Correct |
118 ms |
17916 KB |
Output is correct |
36 |
Correct |
90 ms |
18000 KB |
Output is correct |
37 |
Correct |
224 ms |
17988 KB |
Output is correct |
38 |
Correct |
77 ms |
12368 KB |
Output is correct |
39 |
Correct |
63 ms |
12624 KB |
Output is correct |