#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 3e3 + 5;
ll h, w;
string a [MAXN];
ll sat [MAXN][MAXN];
ll nol [MAXN][MAXN];
int main(){
cin >> h >> w;
for(ll i = 1; i <= h; i++){
cin >> a[i];
}
for(ll i = 1; i <= h; i++){
for(ll j = w-1; j >= 0; j--){
nol[i][j] = nol[i][j+1];
if(a[i][j] == 'O'){
nol[i][j]++;
}
}
}
for(ll j = 0; j < w; j++){
for(ll i = h; i >= 1; i--){
sat[i][j] = sat[i+1][j];
if(a[i][j] == 'I'){
sat[i][j]++;
}
}
}
ll ans = 0;
for(ll i = 1; i <= h; i++){
for(ll j = 0; j < w; j++){
if(a[i][j] == 'J'){
ans += sat[i][j] * nol[i][j];
}
}
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1284 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1284 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
8 ms |
7636 KB |
Output is correct |
15 |
Correct |
3 ms |
3796 KB |
Output is correct |
16 |
Correct |
4 ms |
4724 KB |
Output is correct |
17 |
Correct |
0 ms |
468 KB |
Output is correct |
18 |
Correct |
10 ms |
8788 KB |
Output is correct |
19 |
Correct |
8 ms |
8404 KB |
Output is correct |
20 |
Correct |
8 ms |
8660 KB |
Output is correct |
21 |
Correct |
10 ms |
8788 KB |
Output is correct |
22 |
Correct |
8 ms |
8348 KB |
Output is correct |
23 |
Correct |
8 ms |
8660 KB |
Output is correct |
24 |
Correct |
11 ms |
8752 KB |
Output is correct |
25 |
Correct |
8 ms |
8404 KB |
Output is correct |
26 |
Correct |
9 ms |
8660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1284 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
8 ms |
7636 KB |
Output is correct |
15 |
Correct |
3 ms |
3796 KB |
Output is correct |
16 |
Correct |
4 ms |
4724 KB |
Output is correct |
17 |
Correct |
0 ms |
468 KB |
Output is correct |
18 |
Correct |
10 ms |
8788 KB |
Output is correct |
19 |
Correct |
8 ms |
8404 KB |
Output is correct |
20 |
Correct |
8 ms |
8660 KB |
Output is correct |
21 |
Correct |
10 ms |
8788 KB |
Output is correct |
22 |
Correct |
8 ms |
8348 KB |
Output is correct |
23 |
Correct |
8 ms |
8660 KB |
Output is correct |
24 |
Correct |
11 ms |
8752 KB |
Output is correct |
25 |
Correct |
8 ms |
8404 KB |
Output is correct |
26 |
Correct |
9 ms |
8660 KB |
Output is correct |
27 |
Correct |
384 ms |
152832 KB |
Output is correct |
28 |
Correct |
10 ms |
19540 KB |
Output is correct |
29 |
Correct |
17 ms |
13556 KB |
Output is correct |
30 |
Correct |
1 ms |
852 KB |
Output is correct |
31 |
Correct |
286 ms |
127428 KB |
Output is correct |
32 |
Correct |
363 ms |
152780 KB |
Output is correct |
33 |
Correct |
369 ms |
152332 KB |
Output is correct |
34 |
Correct |
377 ms |
147652 KB |
Output is correct |
35 |
Correct |
367 ms |
152748 KB |
Output is correct |
36 |
Correct |
403 ms |
152264 KB |
Output is correct |
37 |
Correct |
409 ms |
152736 KB |
Output is correct |
38 |
Correct |
274 ms |
126884 KB |
Output is correct |
39 |
Correct |
258 ms |
126864 KB |
Output is correct |