#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define pob pop_back
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vc vector<char>
#define vvc vector<vc>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int h, w;
ll counter = 0;
cin >> h >> w;
vvc data(h, vc(w));
vvi a(h, vi(w)), b(w, vi(h));
for(int i = 0; i < h; i++)
for(int j = 0; j < w; j++)
cin >> data[i][j];
for(int i = 0; i < h; i++){
int ashkan = 0;
for(int j = w - 1; j >= 0; j--){
if(data[i][j] == 'O')
ashkan++;
a[i][j] = ashkan;
}
}
for(int i = 0; i < w; i++){
int ashkan = 0;
for(int j = h - 1; j >= 0; j--){
if(data[j][i] == 'I')
ashkan++;
b[i][j] = ashkan;
}
}
for(int i = 0; i < h; i++)
for(int j = 0; j < w; j++)
if(data[i][j] == 'J')
counter += (ll)(a[i][j] * b[j][i]);
cout << counter;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
496 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
496 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
5 ms |
2136 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
1624 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
2908 KB |
Output is correct |
19 |
Correct |
5 ms |
2744 KB |
Output is correct |
20 |
Correct |
6 ms |
2904 KB |
Output is correct |
21 |
Correct |
10 ms |
2916 KB |
Output is correct |
22 |
Correct |
7 ms |
2652 KB |
Output is correct |
23 |
Correct |
6 ms |
2908 KB |
Output is correct |
24 |
Correct |
8 ms |
2960 KB |
Output is correct |
25 |
Correct |
5 ms |
2648 KB |
Output is correct |
26 |
Correct |
5 ms |
2904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
496 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
5 ms |
2136 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
1624 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
2908 KB |
Output is correct |
19 |
Correct |
5 ms |
2744 KB |
Output is correct |
20 |
Correct |
6 ms |
2904 KB |
Output is correct |
21 |
Correct |
10 ms |
2916 KB |
Output is correct |
22 |
Correct |
7 ms |
2652 KB |
Output is correct |
23 |
Correct |
6 ms |
2908 KB |
Output is correct |
24 |
Correct |
8 ms |
2960 KB |
Output is correct |
25 |
Correct |
5 ms |
2648 KB |
Output is correct |
26 |
Correct |
5 ms |
2904 KB |
Output is correct |
27 |
Correct |
236 ms |
79984 KB |
Output is correct |
28 |
Correct |
1 ms |
856 KB |
Output is correct |
29 |
Correct |
18 ms |
6772 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
182 ms |
59100 KB |
Output is correct |
32 |
Correct |
222 ms |
84136 KB |
Output is correct |
33 |
Correct |
176 ms |
84248 KB |
Output is correct |
34 |
Correct |
189 ms |
68452 KB |
Output is correct |
35 |
Correct |
238 ms |
84136 KB |
Output is correct |
36 |
Correct |
229 ms |
84348 KB |
Output is correct |
37 |
Correct |
263 ms |
84636 KB |
Output is correct |
38 |
Correct |
133 ms |
58684 KB |
Output is correct |
39 |
Correct |
136 ms |
58856 KB |
Output is correct |