#include <bits/stdc++.h>
long long comb[3005][3005][2]={};
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int N,M;
std::cin>>N>>M;
std::string s[N];
for(auto&x:s)std::cin>>x;
for(int i=0;i!=M;++i){
int sum=0;
for(int j=N-1;j!=-1;--j){
if(s[j][i]=='I')++sum;
comb[j][i][0]=sum;
}
}
for(int i=0;i!=N;++i){
int sum=0;
for(int j=M-1;j!=-1;--j){
if(s[i][j]=='O')++sum;
comb[i][j][1]=sum;
}
}
long long total=0;
for(int i=0;i!=N;++i){
for(int j=0;j!=M;++j){
if(s[i][j]=='J'){
total+=comb[i][j][0]*comb[i][j][1];
}
}
}
std::cout<<total<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
844 KB |
Output is correct |
6 |
Correct |
1 ms |
844 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
844 KB |
Output is correct |
9 |
Correct |
1 ms |
844 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
844 KB |
Output is correct |
12 |
Correct |
1 ms |
844 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
844 KB |
Output is correct |
6 |
Correct |
1 ms |
844 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
844 KB |
Output is correct |
9 |
Correct |
1 ms |
844 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
844 KB |
Output is correct |
12 |
Correct |
1 ms |
844 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
14 |
Correct |
6 ms |
5704 KB |
Output is correct |
15 |
Correct |
1 ms |
2112 KB |
Output is correct |
16 |
Correct |
2 ms |
3660 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
6732 KB |
Output is correct |
19 |
Correct |
4 ms |
6484 KB |
Output is correct |
20 |
Correct |
4 ms |
6608 KB |
Output is correct |
21 |
Correct |
7 ms |
6660 KB |
Output is correct |
22 |
Correct |
5 ms |
6456 KB |
Output is correct |
23 |
Correct |
4 ms |
6608 KB |
Output is correct |
24 |
Correct |
6 ms |
6756 KB |
Output is correct |
25 |
Correct |
7 ms |
6484 KB |
Output is correct |
26 |
Correct |
6 ms |
6604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
844 KB |
Output is correct |
6 |
Correct |
1 ms |
844 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
844 KB |
Output is correct |
9 |
Correct |
1 ms |
844 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
844 KB |
Output is correct |
12 |
Correct |
1 ms |
844 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
14 |
Correct |
6 ms |
5704 KB |
Output is correct |
15 |
Correct |
1 ms |
2112 KB |
Output is correct |
16 |
Correct |
2 ms |
3660 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
6732 KB |
Output is correct |
19 |
Correct |
4 ms |
6484 KB |
Output is correct |
20 |
Correct |
4 ms |
6608 KB |
Output is correct |
21 |
Correct |
7 ms |
6660 KB |
Output is correct |
22 |
Correct |
5 ms |
6456 KB |
Output is correct |
23 |
Correct |
4 ms |
6608 KB |
Output is correct |
24 |
Correct |
6 ms |
6756 KB |
Output is correct |
25 |
Correct |
7 ms |
6484 KB |
Output is correct |
26 |
Correct |
6 ms |
6604 KB |
Output is correct |
27 |
Correct |
254 ms |
158920 KB |
Output is correct |
28 |
Correct |
6 ms |
10316 KB |
Output is correct |
29 |
Correct |
12 ms |
12728 KB |
Output is correct |
30 |
Correct |
1 ms |
716 KB |
Output is correct |
31 |
Correct |
190 ms |
120904 KB |
Output is correct |
32 |
Correct |
261 ms |
159892 KB |
Output is correct |
33 |
Correct |
264 ms |
159412 KB |
Output is correct |
34 |
Correct |
227 ms |
140244 KB |
Output is correct |
35 |
Correct |
287 ms |
159792 KB |
Output is correct |
36 |
Correct |
252 ms |
159516 KB |
Output is correct |
37 |
Correct |
284 ms |
159928 KB |
Output is correct |
38 |
Correct |
170 ms |
120092 KB |
Output is correct |
39 |
Correct |
196 ms |
120452 KB |
Output is correct |