#include <bits/stdc++.h>
using namespace std;
char c[3005][3005];
int a[3005][3005];
int b[3005][3005];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m;
cin>>n>>m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin>>c[i][j];
if(c[i][j] == 'O'){
a[i][1]++;
a[i][j]--;
} else if(c[i][j] == 'I'){
b[1][j]++;
b[i][j]--;
}
}
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
a[i][j] += a[i][j - 1];
for(int j = 1; j <= m; j++)
for(int i = 1; i <= n; i++)
b[i][j] += b[i - 1][j];
long long res = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(c[i][j] == 'J'){
res += a[i][j] * b[i][j];
}
}
}
cout<<res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
500 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
4 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
4 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
500 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
4 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
4 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
15 ms |
7544 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
9 ms |
4344 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
8120 KB |
Output is correct |
19 |
Correct |
14 ms |
7928 KB |
Output is correct |
20 |
Correct |
13 ms |
7800 KB |
Output is correct |
21 |
Correct |
17 ms |
8008 KB |
Output is correct |
22 |
Correct |
13 ms |
7928 KB |
Output is correct |
23 |
Correct |
13 ms |
7928 KB |
Output is correct |
24 |
Correct |
18 ms |
8056 KB |
Output is correct |
25 |
Correct |
13 ms |
7928 KB |
Output is correct |
26 |
Correct |
13 ms |
7800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
500 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
4 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
4 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
15 ms |
7544 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
9 ms |
4344 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
8120 KB |
Output is correct |
19 |
Correct |
14 ms |
7928 KB |
Output is correct |
20 |
Correct |
13 ms |
7800 KB |
Output is correct |
21 |
Correct |
17 ms |
8008 KB |
Output is correct |
22 |
Correct |
13 ms |
7928 KB |
Output is correct |
23 |
Correct |
13 ms |
7928 KB |
Output is correct |
24 |
Correct |
18 ms |
8056 KB |
Output is correct |
25 |
Correct |
13 ms |
7928 KB |
Output is correct |
26 |
Correct |
13 ms |
7800 KB |
Output is correct |
27 |
Correct |
467 ms |
88092 KB |
Output is correct |
28 |
Correct |
23 ms |
26104 KB |
Output is correct |
29 |
Correct |
23 ms |
7800 KB |
Output is correct |
30 |
Correct |
3 ms |
632 KB |
Output is correct |
31 |
Correct |
351 ms |
72704 KB |
Output is correct |
32 |
Correct |
371 ms |
88412 KB |
Output is correct |
33 |
Correct |
337 ms |
88156 KB |
Output is correct |
34 |
Correct |
376 ms |
84216 KB |
Output is correct |
35 |
Correct |
365 ms |
88464 KB |
Output is correct |
36 |
Correct |
330 ms |
88408 KB |
Output is correct |
37 |
Correct |
457 ms |
88696 KB |
Output is correct |
38 |
Correct |
245 ms |
72588 KB |
Output is correct |
39 |
Correct |
229 ms |
72412 KB |
Output is correct |