#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3000 + 5;
string s[maxn];
int a[maxn][maxn];
int main(){
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++){
cin >> s[i];
int cnt = 0;
for (int j = m - 1; j >= 0; j--){
cnt += (s[i][j] == 'O');
a[i][j] = cnt;
}
}
ll answer = 0;
for (int j = 0; j < m; j++){
int cnt = 0;
for (int i = n - 1; i >= 0; i--){
cnt += (s[i][j] == 'I');
if (s[i][j] == 'J')
answer += 1ll * a[i][j] * cnt;
}
}
cout << answer << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
424 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
888 KB |
Output is correct |
8 |
Correct |
3 ms |
904 KB |
Output is correct |
9 |
Correct |
2 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
2 ms |
888 KB |
Output is correct |
13 |
Correct |
2 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
424 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
888 KB |
Output is correct |
8 |
Correct |
3 ms |
904 KB |
Output is correct |
9 |
Correct |
2 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
2 ms |
888 KB |
Output is correct |
13 |
Correct |
2 ms |
888 KB |
Output is correct |
14 |
Correct |
6 ms |
3708 KB |
Output is correct |
15 |
Correct |
3 ms |
2168 KB |
Output is correct |
16 |
Correct |
4 ms |
2296 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
7 ms |
3960 KB |
Output is correct |
19 |
Correct |
6 ms |
3832 KB |
Output is correct |
20 |
Correct |
6 ms |
3832 KB |
Output is correct |
21 |
Correct |
10 ms |
3960 KB |
Output is correct |
22 |
Correct |
7 ms |
3832 KB |
Output is correct |
23 |
Correct |
6 ms |
3832 KB |
Output is correct |
24 |
Correct |
7 ms |
3960 KB |
Output is correct |
25 |
Correct |
6 ms |
3832 KB |
Output is correct |
26 |
Correct |
6 ms |
3832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
424 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
888 KB |
Output is correct |
8 |
Correct |
3 ms |
904 KB |
Output is correct |
9 |
Correct |
2 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
2 ms |
888 KB |
Output is correct |
13 |
Correct |
2 ms |
888 KB |
Output is correct |
14 |
Correct |
6 ms |
3708 KB |
Output is correct |
15 |
Correct |
3 ms |
2168 KB |
Output is correct |
16 |
Correct |
4 ms |
2296 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
7 ms |
3960 KB |
Output is correct |
19 |
Correct |
6 ms |
3832 KB |
Output is correct |
20 |
Correct |
6 ms |
3832 KB |
Output is correct |
21 |
Correct |
10 ms |
3960 KB |
Output is correct |
22 |
Correct |
7 ms |
3832 KB |
Output is correct |
23 |
Correct |
6 ms |
3832 KB |
Output is correct |
24 |
Correct |
7 ms |
3960 KB |
Output is correct |
25 |
Correct |
6 ms |
3832 KB |
Output is correct |
26 |
Correct |
6 ms |
3832 KB |
Output is correct |
27 |
Correct |
210 ms |
49472 KB |
Output is correct |
28 |
Correct |
10 ms |
9848 KB |
Output is correct |
29 |
Correct |
9 ms |
4856 KB |
Output is correct |
30 |
Correct |
2 ms |
632 KB |
Output is correct |
31 |
Correct |
144 ms |
41016 KB |
Output is correct |
32 |
Correct |
133 ms |
49784 KB |
Output is correct |
33 |
Correct |
160 ms |
49896 KB |
Output is correct |
34 |
Correct |
166 ms |
46716 KB |
Output is correct |
35 |
Correct |
169 ms |
49864 KB |
Output is correct |
36 |
Correct |
157 ms |
49784 KB |
Output is correct |
37 |
Correct |
235 ms |
49940 KB |
Output is correct |
38 |
Correct |
88 ms |
40824 KB |
Output is correct |
39 |
Correct |
102 ms |
40824 KB |
Output is correct |