#include<bits/stdc++.h>
using namespace std;
string s[3010];
long long oo[3010][3010];
long long ii[3010][3010];
int main(){
int n;
int m;
long long sumi=0;
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>s[i];
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(i==0)
ii[i][j]=0;
if(j==0)
oo[i][j]=0;
if(s[i][j]=='O')
oo[i][j]=oo[i][j-1]+1;
else
oo[i][j]=oo[i][j-1];
if(s[i][j]=='I')
ii[i][j]=ii[i-1][j]+1;
else
ii[i][j]=ii[i-1][j];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(s[i][j]=='J'){
sumi+=(ii[n-1][j]-ii[i][j])*(oo[i][m-1]-oo[i][j]);
}
}
}
cout<<sumi;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
8792 KB |
Output is correct |
6 |
Correct |
1 ms |
8796 KB |
Output is correct |
7 |
Correct |
1 ms |
6748 KB |
Output is correct |
8 |
Correct |
4 ms |
8740 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
8796 KB |
Output is correct |
12 |
Correct |
1 ms |
8796 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
8792 KB |
Output is correct |
6 |
Correct |
1 ms |
8796 KB |
Output is correct |
7 |
Correct |
1 ms |
6748 KB |
Output is correct |
8 |
Correct |
4 ms |
8740 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
8796 KB |
Output is correct |
12 |
Correct |
1 ms |
8796 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
8 ms |
27484 KB |
Output is correct |
15 |
Correct |
3 ms |
23132 KB |
Output is correct |
16 |
Correct |
4 ms |
15196 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
8 ms |
27740 KB |
Output is correct |
19 |
Correct |
7 ms |
27484 KB |
Output is correct |
20 |
Correct |
7 ms |
27724 KB |
Output is correct |
21 |
Correct |
8 ms |
27940 KB |
Output is correct |
22 |
Correct |
8 ms |
27716 KB |
Output is correct |
23 |
Correct |
9 ms |
27984 KB |
Output is correct |
24 |
Correct |
9 ms |
27996 KB |
Output is correct |
25 |
Correct |
7 ms |
27704 KB |
Output is correct |
26 |
Correct |
8 ms |
27740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
8792 KB |
Output is correct |
6 |
Correct |
1 ms |
8796 KB |
Output is correct |
7 |
Correct |
1 ms |
6748 KB |
Output is correct |
8 |
Correct |
4 ms |
8740 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
8796 KB |
Output is correct |
12 |
Correct |
1 ms |
8796 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
8 ms |
27484 KB |
Output is correct |
15 |
Correct |
3 ms |
23132 KB |
Output is correct |
16 |
Correct |
4 ms |
15196 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
8 ms |
27740 KB |
Output is correct |
19 |
Correct |
7 ms |
27484 KB |
Output is correct |
20 |
Correct |
7 ms |
27724 KB |
Output is correct |
21 |
Correct |
8 ms |
27940 KB |
Output is correct |
22 |
Correct |
8 ms |
27716 KB |
Output is correct |
23 |
Correct |
9 ms |
27984 KB |
Output is correct |
24 |
Correct |
9 ms |
27996 KB |
Output is correct |
25 |
Correct |
7 ms |
27704 KB |
Output is correct |
26 |
Correct |
8 ms |
27740 KB |
Output is correct |
27 |
Correct |
204 ms |
161900 KB |
Output is correct |
28 |
Correct |
12 ms |
113244 KB |
Output is correct |
29 |
Correct |
13 ms |
16476 KB |
Output is correct |
30 |
Correct |
1 ms |
4700 KB |
Output is correct |
31 |
Correct |
137 ms |
137200 KB |
Output is correct |
32 |
Correct |
175 ms |
162220 KB |
Output is correct |
33 |
Correct |
167 ms |
162316 KB |
Output is correct |
34 |
Correct |
157 ms |
158036 KB |
Output is correct |
35 |
Correct |
176 ms |
162096 KB |
Output is correct |
36 |
Correct |
170 ms |
162128 KB |
Output is correct |
37 |
Correct |
202 ms |
162396 KB |
Output is correct |
38 |
Correct |
126 ms |
137484 KB |
Output is correct |
39 |
Correct |
120 ms |
137200 KB |
Output is correct |