#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int nmax = 3e3 + 2;
long long o[nmax][nmax], I[nmax][nmax], h, w, ans;
string s[nmax];
int main(){
faster
cin >> h >> w;
for(int i = 1; i <= h; i++){
cin >> s[i];
s[i] = " " + s[i];
}
for(int i = h; i >= 1; i--){
for(int j = w; j >= 1; j--){
o[i][j] = o[i][j + 1] + (s[i][j] == 'O');
I[i][j] = I[i + 1][j] + (s[i][j] == 'I');
if(s[i][j] == 'J')ans += o[i][j]*I[i][j];
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
5 ms |
7772 KB |
Output is correct |
15 |
Correct |
2 ms |
3892 KB |
Output is correct |
16 |
Correct |
2 ms |
4696 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
4 ms |
8796 KB |
Output is correct |
19 |
Correct |
4 ms |
8796 KB |
Output is correct |
20 |
Correct |
4 ms |
8796 KB |
Output is correct |
21 |
Correct |
5 ms |
8796 KB |
Output is correct |
22 |
Correct |
5 ms |
8712 KB |
Output is correct |
23 |
Correct |
4 ms |
8796 KB |
Output is correct |
24 |
Correct |
4 ms |
8796 KB |
Output is correct |
25 |
Correct |
4 ms |
8792 KB |
Output is correct |
26 |
Correct |
4 ms |
8856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
5 ms |
7772 KB |
Output is correct |
15 |
Correct |
2 ms |
3892 KB |
Output is correct |
16 |
Correct |
2 ms |
4696 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
4 ms |
8796 KB |
Output is correct |
19 |
Correct |
4 ms |
8796 KB |
Output is correct |
20 |
Correct |
4 ms |
8796 KB |
Output is correct |
21 |
Correct |
5 ms |
8796 KB |
Output is correct |
22 |
Correct |
5 ms |
8712 KB |
Output is correct |
23 |
Correct |
4 ms |
8796 KB |
Output is correct |
24 |
Correct |
4 ms |
8796 KB |
Output is correct |
25 |
Correct |
4 ms |
8792 KB |
Output is correct |
26 |
Correct |
4 ms |
8856 KB |
Output is correct |
27 |
Correct |
102 ms |
156496 KB |
Output is correct |
28 |
Correct |
8 ms |
19548 KB |
Output is correct |
29 |
Correct |
8 ms |
13912 KB |
Output is correct |
30 |
Correct |
1 ms |
856 KB |
Output is correct |
31 |
Correct |
80 ms |
128988 KB |
Output is correct |
32 |
Correct |
91 ms |
157092 KB |
Output is correct |
33 |
Correct |
88 ms |
157396 KB |
Output is correct |
34 |
Correct |
97 ms |
149724 KB |
Output is correct |
35 |
Correct |
93 ms |
157164 KB |
Output is correct |
36 |
Correct |
90 ms |
156844 KB |
Output is correct |
37 |
Correct |
107 ms |
157268 KB |
Output is correct |
38 |
Correct |
69 ms |
128592 KB |
Output is correct |
39 |
Correct |
72 ms |
128428 KB |
Output is correct |