#include<bits/stdc++.h>
using namespace std;
const int mx=3002;
typedef long long ll;
int inf=1e9+10;
const int mod=1e9+7;
int n,m;
int dp[mx][mx];
int dp2[mx][mx];
string s[mx];
int main(){
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>s[i];
}
for(int i=0;i<n;i++){
for(int j=m-1;j>=0;j--){
dp[i][j]=(s[i][j]=='O')+dp[i][j+1];
}
}
ll ans=0;
for(int i=n-1;i>=0;i--){
for(int j=m-1;j>=0;j--){
dp2[i][j]=(s[i][j]=='I')+dp2[i+1][j];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(s[i][j]=='J'){
ans+=dp[i][j]*dp2[i][j];
}
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
396 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
1228 KB |
Output is correct |
6 |
Correct |
2 ms |
1228 KB |
Output is correct |
7 |
Correct |
2 ms |
1168 KB |
Output is correct |
8 |
Correct |
2 ms |
1228 KB |
Output is correct |
9 |
Correct |
2 ms |
1228 KB |
Output is correct |
10 |
Correct |
2 ms |
1100 KB |
Output is correct |
11 |
Correct |
2 ms |
1228 KB |
Output is correct |
12 |
Correct |
2 ms |
1228 KB |
Output is correct |
13 |
Correct |
2 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
396 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
1228 KB |
Output is correct |
6 |
Correct |
2 ms |
1228 KB |
Output is correct |
7 |
Correct |
2 ms |
1168 KB |
Output is correct |
8 |
Correct |
2 ms |
1228 KB |
Output is correct |
9 |
Correct |
2 ms |
1228 KB |
Output is correct |
10 |
Correct |
2 ms |
1100 KB |
Output is correct |
11 |
Correct |
2 ms |
1228 KB |
Output is correct |
12 |
Correct |
2 ms |
1228 KB |
Output is correct |
13 |
Correct |
2 ms |
1100 KB |
Output is correct |
14 |
Correct |
10 ms |
6348 KB |
Output is correct |
15 |
Correct |
4 ms |
3788 KB |
Output is correct |
16 |
Correct |
7 ms |
3812 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
13 ms |
7096 KB |
Output is correct |
19 |
Correct |
11 ms |
6728 KB |
Output is correct |
20 |
Correct |
11 ms |
6860 KB |
Output is correct |
21 |
Correct |
13 ms |
7100 KB |
Output is correct |
22 |
Correct |
11 ms |
6684 KB |
Output is correct |
23 |
Correct |
11 ms |
6936 KB |
Output is correct |
24 |
Correct |
13 ms |
6988 KB |
Output is correct |
25 |
Correct |
11 ms |
6692 KB |
Output is correct |
26 |
Correct |
11 ms |
6876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
396 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
1228 KB |
Output is correct |
6 |
Correct |
2 ms |
1228 KB |
Output is correct |
7 |
Correct |
2 ms |
1168 KB |
Output is correct |
8 |
Correct |
2 ms |
1228 KB |
Output is correct |
9 |
Correct |
2 ms |
1228 KB |
Output is correct |
10 |
Correct |
2 ms |
1100 KB |
Output is correct |
11 |
Correct |
2 ms |
1228 KB |
Output is correct |
12 |
Correct |
2 ms |
1228 KB |
Output is correct |
13 |
Correct |
2 ms |
1100 KB |
Output is correct |
14 |
Correct |
10 ms |
6348 KB |
Output is correct |
15 |
Correct |
4 ms |
3788 KB |
Output is correct |
16 |
Correct |
7 ms |
3812 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
13 ms |
7096 KB |
Output is correct |
19 |
Correct |
11 ms |
6728 KB |
Output is correct |
20 |
Correct |
11 ms |
6860 KB |
Output is correct |
21 |
Correct |
13 ms |
7100 KB |
Output is correct |
22 |
Correct |
11 ms |
6684 KB |
Output is correct |
23 |
Correct |
11 ms |
6936 KB |
Output is correct |
24 |
Correct |
13 ms |
6988 KB |
Output is correct |
25 |
Correct |
11 ms |
6692 KB |
Output is correct |
26 |
Correct |
11 ms |
6876 KB |
Output is correct |
27 |
Correct |
300 ms |
90464 KB |
Output is correct |
28 |
Correct |
12 ms |
19276 KB |
Output is correct |
29 |
Correct |
24 ms |
8064 KB |
Output is correct |
30 |
Correct |
2 ms |
588 KB |
Output is correct |
31 |
Correct |
233 ms |
74884 KB |
Output is correct |
32 |
Correct |
283 ms |
90896 KB |
Output is correct |
33 |
Correct |
290 ms |
90768 KB |
Output is correct |
34 |
Correct |
260 ms |
86608 KB |
Output is correct |
35 |
Correct |
286 ms |
90828 KB |
Output is correct |
36 |
Correct |
290 ms |
90736 KB |
Output is correct |
37 |
Correct |
320 ms |
91004 KB |
Output is correct |
38 |
Correct |
219 ms |
74536 KB |
Output is correct |
39 |
Correct |
202 ms |
74296 KB |
Output is correct |