#include "bits/stdc++.h"
#define int long long
using namespace std;
const int MAXN = 1e6 + 10;
int32_t main() {
int h, w;cin >> h >> w;
char a[h+1][w+1];
int O[h+1][w+1];
int I[h+1][w+1];
for(int i=0; i<=h; i++) {
for(int j=0; j<=w; j++) {
O[i][j] = I[i][j] = 0;
}
}
for(int i=1;i <=h; i++) {
for(int j=1; j<=w; j++) {
cin >> a[i][j];
O[i][j] = O[i][j-1] + (a[i][j] == 'O');
I[i][j] = I[i-1][j] + (a[i][j] == 'I');
}
}
int ans= 0;;
for(int i=1; i<=h;i ++) {
for(int j=1; j<=w; j++) {
if(a[i][j] == 'J') {
ans += (O[i][w] - O[i][j]) * (I[h][j] - I[i][j]);
}
}
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
248 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
420 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
248 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
420 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
14 ms |
3660 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
9 ms |
2480 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
18 ms |
4632 KB |
Output is correct |
19 |
Correct |
16 ms |
4428 KB |
Output is correct |
20 |
Correct |
17 ms |
4524 KB |
Output is correct |
21 |
Correct |
17 ms |
4708 KB |
Output is correct |
22 |
Correct |
16 ms |
4420 KB |
Output is correct |
23 |
Correct |
17 ms |
4592 KB |
Output is correct |
24 |
Correct |
17 ms |
4676 KB |
Output is correct |
25 |
Correct |
16 ms |
4388 KB |
Output is correct |
26 |
Correct |
16 ms |
4528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
248 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
420 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
14 ms |
3660 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
9 ms |
2480 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
18 ms |
4632 KB |
Output is correct |
19 |
Correct |
16 ms |
4428 KB |
Output is correct |
20 |
Correct |
17 ms |
4524 KB |
Output is correct |
21 |
Correct |
17 ms |
4708 KB |
Output is correct |
22 |
Correct |
16 ms |
4420 KB |
Output is correct |
23 |
Correct |
17 ms |
4592 KB |
Output is correct |
24 |
Correct |
17 ms |
4676 KB |
Output is correct |
25 |
Correct |
16 ms |
4388 KB |
Output is correct |
26 |
Correct |
16 ms |
4528 KB |
Output is correct |
27 |
Correct |
623 ms |
150104 KB |
Output is correct |
28 |
Correct |
2 ms |
716 KB |
Output is correct |
29 |
Correct |
43 ms |
11652 KB |
Output is correct |
30 |
Correct |
2 ms |
716 KB |
Output is correct |
31 |
Correct |
422 ms |
110364 KB |
Output is correct |
32 |
Correct |
577 ms |
157756 KB |
Output is correct |
33 |
Correct |
601 ms |
158304 KB |
Output is correct |
34 |
Correct |
480 ms |
127940 KB |
Output is correct |
35 |
Correct |
574 ms |
157756 KB |
Output is correct |
36 |
Correct |
567 ms |
158260 KB |
Output is correct |
37 |
Correct |
608 ms |
158756 KB |
Output is correct |
38 |
Correct |
404 ms |
109536 KB |
Output is correct |
39 |
Correct |
396 ms |
109960 KB |
Output is correct |