#include<iostream>
using namespace std;
int const N = 3e3 + 5;
typedef long long LL;
char a[N][N];
LL icnt[N];
int main(){
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> a[i][j];
}
}
LL ans = 0;
for(int i = n - 1; i >= 0; i--){
LL ocnt = 0;
for(int j = m - 1; j >= 0; j--){
if(a[i][j] == 'J'){
ans += icnt[j] * ocnt;
}else if(a[i][j] == 'I'){
icnt[j]++;
}else{
ocnt++;
}
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
276 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
556 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
276 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
556 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
13 ms |
1884 KB |
Output is correct |
15 |
Correct |
1 ms |
1484 KB |
Output is correct |
16 |
Correct |
8 ms |
1100 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
16 ms |
1940 KB |
Output is correct |
19 |
Correct |
15 ms |
1988 KB |
Output is correct |
20 |
Correct |
14 ms |
1972 KB |
Output is correct |
21 |
Correct |
15 ms |
1876 KB |
Output is correct |
22 |
Correct |
14 ms |
1864 KB |
Output is correct |
23 |
Correct |
15 ms |
1964 KB |
Output is correct |
24 |
Correct |
16 ms |
1964 KB |
Output is correct |
25 |
Correct |
15 ms |
1952 KB |
Output is correct |
26 |
Correct |
14 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
276 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
556 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
13 ms |
1884 KB |
Output is correct |
15 |
Correct |
1 ms |
1484 KB |
Output is correct |
16 |
Correct |
8 ms |
1100 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
16 ms |
1940 KB |
Output is correct |
19 |
Correct |
15 ms |
1988 KB |
Output is correct |
20 |
Correct |
14 ms |
1972 KB |
Output is correct |
21 |
Correct |
15 ms |
1876 KB |
Output is correct |
22 |
Correct |
14 ms |
1864 KB |
Output is correct |
23 |
Correct |
15 ms |
1964 KB |
Output is correct |
24 |
Correct |
16 ms |
1964 KB |
Output is correct |
25 |
Correct |
15 ms |
1952 KB |
Output is correct |
26 |
Correct |
14 ms |
1868 KB |
Output is correct |
27 |
Correct |
504 ms |
17312 KB |
Output is correct |
28 |
Correct |
4 ms |
7116 KB |
Output is correct |
29 |
Correct |
38 ms |
1720 KB |
Output is correct |
30 |
Correct |
2 ms |
312 KB |
Output is correct |
31 |
Correct |
366 ms |
13688 KB |
Output is correct |
32 |
Correct |
491 ms |
17888 KB |
Output is correct |
33 |
Correct |
483 ms |
17784 KB |
Output is correct |
34 |
Correct |
429 ms |
15824 KB |
Output is correct |
35 |
Correct |
485 ms |
17920 KB |
Output is correct |
36 |
Correct |
488 ms |
17828 KB |
Output is correct |
37 |
Correct |
537 ms |
17860 KB |
Output is correct |
38 |
Correct |
338 ms |
13780 KB |
Output is correct |
39 |
Correct |
335 ms |
13636 KB |
Output is correct |