#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3+45;
char a[N][N];
int cnti[N][N],cnto[N][N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int h,w;
cin >> h >> w;
for(int i = 1; i <= h; i++){
string s;
cin >> s;
for(int j = 1; j <= w; j++){
a[i][j] = s[j-1];
cnto[i][j] = cnto[i][j-1]+(a[i][j] == 'O');
}
}
for(int j = 1; j <= w; j++){
for(int i = 1; i <= h; i++){
cnti[j][i] = cnti[j][i-1]+(a[i][j] == 'I');
}
}
ll sol = 0;
for(int i = 1; i <= h; i++){
for(int j = 1; j <= w; j++){
if(a[i][j] != 'J'){
continue;
}
ll iovi = cnti[j][h]-cnti[j][i-1],oovi = cnto[i][w]-cnto[i][j-1];
sol += iovi*oovi;
}
}
cout << sol << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1528 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
1528 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1400 KB |
Output is correct |
13 |
Correct |
3 ms |
1532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1528 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
1528 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1400 KB |
Output is correct |
13 |
Correct |
3 ms |
1532 KB |
Output is correct |
14 |
Correct |
11 ms |
7032 KB |
Output is correct |
15 |
Correct |
5 ms |
3320 KB |
Output is correct |
16 |
Correct |
8 ms |
5368 KB |
Output is correct |
17 |
Correct |
3 ms |
1656 KB |
Output is correct |
18 |
Correct |
12 ms |
8056 KB |
Output is correct |
19 |
Correct |
11 ms |
7928 KB |
Output is correct |
20 |
Correct |
12 ms |
7928 KB |
Output is correct |
21 |
Correct |
13 ms |
8056 KB |
Output is correct |
22 |
Correct |
11 ms |
7932 KB |
Output is correct |
23 |
Correct |
11 ms |
7928 KB |
Output is correct |
24 |
Correct |
13 ms |
8056 KB |
Output is correct |
25 |
Correct |
11 ms |
7928 KB |
Output is correct |
26 |
Correct |
11 ms |
7928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1528 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
1528 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1400 KB |
Output is correct |
13 |
Correct |
3 ms |
1532 KB |
Output is correct |
14 |
Correct |
11 ms |
7032 KB |
Output is correct |
15 |
Correct |
5 ms |
3320 KB |
Output is correct |
16 |
Correct |
8 ms |
5368 KB |
Output is correct |
17 |
Correct |
3 ms |
1656 KB |
Output is correct |
18 |
Correct |
12 ms |
8056 KB |
Output is correct |
19 |
Correct |
11 ms |
7928 KB |
Output is correct |
20 |
Correct |
12 ms |
7928 KB |
Output is correct |
21 |
Correct |
13 ms |
8056 KB |
Output is correct |
22 |
Correct |
11 ms |
7932 KB |
Output is correct |
23 |
Correct |
11 ms |
7928 KB |
Output is correct |
24 |
Correct |
13 ms |
8056 KB |
Output is correct |
25 |
Correct |
11 ms |
7928 KB |
Output is correct |
26 |
Correct |
11 ms |
7928 KB |
Output is correct |
27 |
Correct |
211 ms |
87260 KB |
Output is correct |
28 |
Correct |
19 ms |
16888 KB |
Output is correct |
29 |
Correct |
27 ms |
17400 KB |
Output is correct |
30 |
Correct |
13 ms |
9848 KB |
Output is correct |
31 |
Correct |
157 ms |
73592 KB |
Output is correct |
32 |
Correct |
165 ms |
89328 KB |
Output is correct |
33 |
Correct |
186 ms |
89380 KB |
Output is correct |
34 |
Correct |
179 ms |
80476 KB |
Output is correct |
35 |
Correct |
191 ms |
89364 KB |
Output is correct |
36 |
Correct |
180 ms |
89468 KB |
Output is correct |
37 |
Correct |
223 ms |
89592 KB |
Output is correct |
38 |
Correct |
125 ms |
73208 KB |
Output is correct |
39 |
Correct |
157 ms |
73308 KB |
Output is correct |