#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int R, C;
char grid[3005][3005];
ll ans = 0, numI[3005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> R >> C;
for (int i = 1; i <= R; ++i){
for (int j = 1; j <= C; ++j){
cin >> grid[i][j];
}
}
for (int i = R; i >= 1; --i){
ll ocnt = 0;
for (int j = C; j >= 1; --j){
if (grid[i][j] == 'O') ocnt++;
if (grid[i][j] == 'I') numI[j]++;
if (grid[i][j] == 'J') ans += ocnt * numI[j];
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
636 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
6 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
632 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
636 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
6 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
632 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
636 KB |
Output is correct |
14 |
Correct |
12 ms |
1788 KB |
Output is correct |
15 |
Correct |
5 ms |
1656 KB |
Output is correct |
16 |
Correct |
7 ms |
1144 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
10 ms |
1784 KB |
Output is correct |
19 |
Correct |
9 ms |
1784 KB |
Output is correct |
20 |
Correct |
10 ms |
1784 KB |
Output is correct |
21 |
Correct |
10 ms |
1784 KB |
Output is correct |
22 |
Correct |
9 ms |
1784 KB |
Output is correct |
23 |
Correct |
8 ms |
1784 KB |
Output is correct |
24 |
Correct |
10 ms |
1784 KB |
Output is correct |
25 |
Correct |
9 ms |
1788 KB |
Output is correct |
26 |
Correct |
9 ms |
1784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
636 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
6 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
632 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
636 KB |
Output is correct |
14 |
Correct |
12 ms |
1788 KB |
Output is correct |
15 |
Correct |
5 ms |
1656 KB |
Output is correct |
16 |
Correct |
7 ms |
1144 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
10 ms |
1784 KB |
Output is correct |
19 |
Correct |
9 ms |
1784 KB |
Output is correct |
20 |
Correct |
10 ms |
1784 KB |
Output is correct |
21 |
Correct |
10 ms |
1784 KB |
Output is correct |
22 |
Correct |
9 ms |
1784 KB |
Output is correct |
23 |
Correct |
8 ms |
1784 KB |
Output is correct |
24 |
Correct |
10 ms |
1784 KB |
Output is correct |
25 |
Correct |
9 ms |
1788 KB |
Output is correct |
26 |
Correct |
9 ms |
1784 KB |
Output is correct |
27 |
Correct |
188 ms |
9208 KB |
Output is correct |
28 |
Correct |
8 ms |
7160 KB |
Output is correct |
29 |
Correct |
15 ms |
1144 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
138 ms |
7776 KB |
Output is correct |
32 |
Correct |
142 ms |
9208 KB |
Output is correct |
33 |
Correct |
131 ms |
9208 KB |
Output is correct |
34 |
Correct |
162 ms |
9016 KB |
Output is correct |
35 |
Correct |
141 ms |
9208 KB |
Output is correct |
36 |
Correct |
133 ms |
9208 KB |
Output is correct |
37 |
Correct |
189 ms |
9208 KB |
Output is correct |
38 |
Correct |
100 ms |
7672 KB |
Output is correct |
39 |
Correct |
97 ms |
7672 KB |
Output is correct |