#include "bits/stdc++.h"
using namespace std;
int ans[3005][3005];
char arr[3005][3005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m;
cin >> n >> m;
vector<pair<int,int>> list;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> arr[i][j];
}
}
for(int j = m-1; j >= 0; j--){
int o = 0;
for(int i = n-1; i >= 0; i--){
if(arr[i][j] == 'I') o++;
if(arr[i][j] == 'J') {
ans[i][j] = o;
}
}
}
for(int i = n-1; i >= 0; i--){
int o = 0;
for(int j = m-1; j >= 0; j--){
if(arr[i][j] == 'O') o++;
if(arr[i][j] == 'J') {
list.push_back(make_pair(i,j));
ans[i][j] *= o;
}
}
}
long long int ansss = 0;
for(int i = 0; i < (int)list.size(); i++) ansss += ans[list[i].first][list[i].second];
cout << ansss << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
1100 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
968 KB |
Output is correct |
8 |
Correct |
1 ms |
1100 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
1100 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
1100 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
968 KB |
Output is correct |
8 |
Correct |
1 ms |
1100 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
1100 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
9 ms |
5356 KB |
Output is correct |
15 |
Correct |
2 ms |
3148 KB |
Output is correct |
16 |
Correct |
5 ms |
3152 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
15 ms |
6092 KB |
Output is correct |
19 |
Correct |
9 ms |
4816 KB |
Output is correct |
20 |
Correct |
9 ms |
5452 KB |
Output is correct |
21 |
Correct |
12 ms |
6112 KB |
Output is correct |
22 |
Correct |
9 ms |
5864 KB |
Output is correct |
23 |
Correct |
8 ms |
5452 KB |
Output is correct |
24 |
Correct |
11 ms |
6100 KB |
Output is correct |
25 |
Correct |
8 ms |
4884 KB |
Output is correct |
26 |
Correct |
9 ms |
5452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
1100 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
968 KB |
Output is correct |
8 |
Correct |
1 ms |
1100 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
1100 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
9 ms |
5356 KB |
Output is correct |
15 |
Correct |
2 ms |
3148 KB |
Output is correct |
16 |
Correct |
5 ms |
3152 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
15 ms |
6092 KB |
Output is correct |
19 |
Correct |
9 ms |
4816 KB |
Output is correct |
20 |
Correct |
9 ms |
5452 KB |
Output is correct |
21 |
Correct |
12 ms |
6112 KB |
Output is correct |
22 |
Correct |
9 ms |
5864 KB |
Output is correct |
23 |
Correct |
8 ms |
5452 KB |
Output is correct |
24 |
Correct |
11 ms |
6100 KB |
Output is correct |
25 |
Correct |
8 ms |
4884 KB |
Output is correct |
26 |
Correct |
9 ms |
5452 KB |
Output is correct |
27 |
Correct |
377 ms |
85680 KB |
Output is correct |
28 |
Correct |
8 ms |
16076 KB |
Output is correct |
29 |
Correct |
17 ms |
5716 KB |
Output is correct |
30 |
Correct |
2 ms |
588 KB |
Output is correct |
31 |
Correct |
269 ms |
59676 KB |
Output is correct |
32 |
Correct |
245 ms |
53984 KB |
Output is correct |
33 |
Correct |
309 ms |
74072 KB |
Output is correct |
34 |
Correct |
325 ms |
82936 KB |
Output is correct |
35 |
Correct |
308 ms |
80396 KB |
Output is correct |
36 |
Correct |
305 ms |
74084 KB |
Output is correct |
37 |
Correct |
382 ms |
85684 KB |
Output is correct |
38 |
Correct |
169 ms |
44312 KB |
Output is correct |
39 |
Correct |
219 ms |
48384 KB |
Output is correct |