#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
vector<pair<int,int>> jw;
vector<vector<int>> orb, ing;
orb = ing = vector<vector<int>>(n, vector<int>(m));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
char c; cin >> c;
if(c == 'J') jw.emplace_back(i, j);
else if(c == 'I') ing[i][j]++;
else if(c == 'O') orb[i][j]++;
}
}
for(int i = 0; i < n; i++){
for(int j = m - 2; j >= 0; j--){
orb[i][j] += orb[i][j + 1];
}
}
for(int i = 0; i < m; i++){
for(int j = n - 2; j >= 0; j--){
ing[j][i] += ing[j+1][i];
}
}
int res = 0;
for(pair<int,int> j : jw){
res += orb[j.first][j.second] * ing[j.first][j.second];
}
cout << res << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
720 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
2 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
720 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
2 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
9 ms |
4816 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
5 ms |
3784 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
11 ms |
6856 KB |
Output is correct |
19 |
Correct |
7 ms |
5068 KB |
Output is correct |
20 |
Correct |
8 ms |
6852 KB |
Output is correct |
21 |
Correct |
11 ms |
6600 KB |
Output is correct |
22 |
Correct |
11 ms |
6572 KB |
Output is correct |
23 |
Correct |
8 ms |
6768 KB |
Output is correct |
24 |
Correct |
11 ms |
6600 KB |
Output is correct |
25 |
Correct |
7 ms |
5068 KB |
Output is correct |
26 |
Correct |
10 ms |
6640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
720 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
2 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
9 ms |
4816 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
5 ms |
3784 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
11 ms |
6856 KB |
Output is correct |
19 |
Correct |
7 ms |
5068 KB |
Output is correct |
20 |
Correct |
8 ms |
6852 KB |
Output is correct |
21 |
Correct |
11 ms |
6600 KB |
Output is correct |
22 |
Correct |
11 ms |
6572 KB |
Output is correct |
23 |
Correct |
8 ms |
6768 KB |
Output is correct |
24 |
Correct |
11 ms |
6600 KB |
Output is correct |
25 |
Correct |
7 ms |
5068 KB |
Output is correct |
26 |
Correct |
10 ms |
6640 KB |
Output is correct |
27 |
Correct |
389 ms |
205800 KB |
Output is correct |
28 |
Correct |
2 ms |
1360 KB |
Output is correct |
29 |
Correct |
20 ms |
15316 KB |
Output is correct |
30 |
Correct |
2 ms |
848 KB |
Output is correct |
31 |
Correct |
270 ms |
137216 KB |
Output is correct |
32 |
Correct |
264 ms |
162948 KB |
Output is correct |
33 |
Correct |
311 ms |
211072 KB |
Output is correct |
34 |
Correct |
309 ms |
186208 KB |
Output is correct |
35 |
Correct |
300 ms |
212828 KB |
Output is correct |
36 |
Correct |
311 ms |
211128 KB |
Output is correct |
37 |
Correct |
419 ms |
212676 KB |
Output is correct |
38 |
Correct |
190 ms |
119208 KB |
Output is correct |
39 |
Correct |
207 ms |
136592 KB |
Output is correct |