#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, k, ans = 0; cin >> n >> k;
char ch[n][k];
int cnt[n][k], cnt2[n][k];
for (int i = 0; i < n; i++){
for (int j = 0; j < k; j++){
cin >> ch[i][j];
}
}
for (int i = n - 1; i >= 0; i--){
for (int j = k - 1; j >= 0; j--){
if (i == n - 1) cnt[i][j] = 0;
else cnt[i][j] = cnt[i + 1][j];
if (j == k - 1) cnt2[i][j] = 0;
else cnt2[i][j] = cnt2[i][j + 1];
if (ch[i][j] == 'I') cnt[i][j]++;
if (ch[i][j] == 'O') cnt2[i][j]++;
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < k; j++){
if (ch[i][j] == 'J') ans += cnt[i][j] * cnt2[i][j];
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
232 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
408 KB |
Output is correct |
7 |
Correct |
1 ms |
452 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
456 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
448 KB |
Output is correct |
13 |
Correct |
1 ms |
452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
232 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
408 KB |
Output is correct |
7 |
Correct |
1 ms |
452 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
456 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
448 KB |
Output is correct |
13 |
Correct |
1 ms |
452 KB |
Output is correct |
14 |
Correct |
6 ms |
3656 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
4 ms |
2516 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
9 ms |
4692 KB |
Output is correct |
19 |
Correct |
7 ms |
4436 KB |
Output is correct |
20 |
Correct |
7 ms |
4564 KB |
Output is correct |
21 |
Correct |
8 ms |
4716 KB |
Output is correct |
22 |
Correct |
8 ms |
4416 KB |
Output is correct |
23 |
Correct |
6 ms |
4564 KB |
Output is correct |
24 |
Correct |
8 ms |
4692 KB |
Output is correct |
25 |
Correct |
7 ms |
4436 KB |
Output is correct |
26 |
Correct |
6 ms |
4564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
232 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
408 KB |
Output is correct |
7 |
Correct |
1 ms |
452 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
456 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
448 KB |
Output is correct |
13 |
Correct |
1 ms |
452 KB |
Output is correct |
14 |
Correct |
6 ms |
3656 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
4 ms |
2516 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
9 ms |
4692 KB |
Output is correct |
19 |
Correct |
7 ms |
4436 KB |
Output is correct |
20 |
Correct |
7 ms |
4564 KB |
Output is correct |
21 |
Correct |
8 ms |
4716 KB |
Output is correct |
22 |
Correct |
8 ms |
4416 KB |
Output is correct |
23 |
Correct |
6 ms |
4564 KB |
Output is correct |
24 |
Correct |
8 ms |
4692 KB |
Output is correct |
25 |
Correct |
7 ms |
4436 KB |
Output is correct |
26 |
Correct |
6 ms |
4564 KB |
Output is correct |
27 |
Correct |
256 ms |
150000 KB |
Output is correct |
28 |
Correct |
1 ms |
724 KB |
Output is correct |
29 |
Correct |
20 ms |
11712 KB |
Output is correct |
30 |
Correct |
1 ms |
724 KB |
Output is correct |
31 |
Correct |
189 ms |
110380 KB |
Output is correct |
32 |
Correct |
198 ms |
157708 KB |
Output is correct |
33 |
Correct |
214 ms |
158288 KB |
Output is correct |
34 |
Correct |
214 ms |
127868 KB |
Output is correct |
35 |
Correct |
198 ms |
157712 KB |
Output is correct |
36 |
Correct |
193 ms |
158368 KB |
Output is correct |
37 |
Correct |
274 ms |
158812 KB |
Output is correct |
38 |
Correct |
149 ms |
109508 KB |
Output is correct |
39 |
Correct |
139 ms |
109932 KB |
Output is correct |