#include <bits/stdc++.h>
using namespace std;
int N, M;
int ingot[3005][3005];
int orb[3005][3005];
char mp[3005][3005];
int main(){
cin.sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> M;
for(int i = 1; i<=N; i++){
for(int j = 1; j<=M; j++){
cin >> mp[i][j];
}
}
for(int i = 1; i<=N; i++){
for(int j = M; j; j--){
orb[i][j] = orb[i][j+1] + (mp[i][j] == 'O');
}
}
for(int i = 1; i<=M; i++){
for(int j = N; j; j--){
ingot[j][i] = ingot[j+1][i] + (mp[j][i] == 'I');
}
}
long long ans = 0;
for(int i = 1; i<=N; i++){
for(int j = 1; j<=M; j++){
if(mp[i][j] == 'J'){
ans += ingot[i][j] * orb[i][j];
}
}
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1536 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1536 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
14 |
Correct |
14 ms |
7552 KB |
Output is correct |
15 |
Correct |
7 ms |
4992 KB |
Output is correct |
16 |
Correct |
9 ms |
4352 KB |
Output is correct |
17 |
Correct |
5 ms |
560 KB |
Output is correct |
18 |
Correct |
17 ms |
8112 KB |
Output is correct |
19 |
Correct |
13 ms |
7936 KB |
Output is correct |
20 |
Correct |
13 ms |
7936 KB |
Output is correct |
21 |
Correct |
15 ms |
8064 KB |
Output is correct |
22 |
Correct |
13 ms |
7936 KB |
Output is correct |
23 |
Correct |
13 ms |
7936 KB |
Output is correct |
24 |
Correct |
15 ms |
8064 KB |
Output is correct |
25 |
Correct |
13 ms |
7936 KB |
Output is correct |
26 |
Correct |
14 ms |
7936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1536 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
14 |
Correct |
14 ms |
7552 KB |
Output is correct |
15 |
Correct |
7 ms |
4992 KB |
Output is correct |
16 |
Correct |
9 ms |
4352 KB |
Output is correct |
17 |
Correct |
5 ms |
560 KB |
Output is correct |
18 |
Correct |
17 ms |
8112 KB |
Output is correct |
19 |
Correct |
13 ms |
7936 KB |
Output is correct |
20 |
Correct |
13 ms |
7936 KB |
Output is correct |
21 |
Correct |
15 ms |
8064 KB |
Output is correct |
22 |
Correct |
13 ms |
7936 KB |
Output is correct |
23 |
Correct |
13 ms |
7936 KB |
Output is correct |
24 |
Correct |
15 ms |
8064 KB |
Output is correct |
25 |
Correct |
13 ms |
7936 KB |
Output is correct |
26 |
Correct |
14 ms |
7936 KB |
Output is correct |
27 |
Correct |
372 ms |
88056 KB |
Output is correct |
28 |
Correct |
18 ms |
26112 KB |
Output is correct |
29 |
Correct |
21 ms |
7928 KB |
Output is correct |
30 |
Correct |
5 ms |
640 KB |
Output is correct |
31 |
Correct |
277 ms |
72696 KB |
Output is correct |
32 |
Correct |
355 ms |
88440 KB |
Output is correct |
33 |
Correct |
351 ms |
88312 KB |
Output is correct |
34 |
Correct |
315 ms |
84216 KB |
Output is correct |
35 |
Correct |
362 ms |
88440 KB |
Output is correct |
36 |
Correct |
362 ms |
88312 KB |
Output is correct |
37 |
Correct |
397 ms |
88568 KB |
Output is correct |
38 |
Correct |
250 ms |
72568 KB |
Output is correct |
39 |
Correct |
253 ms |
72440 KB |
Output is correct |