#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=3e3+5;
int n,m;
string s;
char c[mxn][mxn];
int rast[mxn][mxn],pain[mxn][mxn];
ll ans;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>s;
for(int j=0;j<m;j++)
c[i][j]=s[j];
}
for(int i=n-1;i>=0;i--){
for(int j=m-1;j>=0;j--){
if(i!=n-1)pain[i][j]=pain[i+1][j]+(c[i+1][j]=='I');
if(j!=m-1)rast[i][j]=rast[i][j+1]+(c[i][j+1]=='O');
if(c[i][j]=='J')ans+=(ll)pain[i][j]*rast[i][j];
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 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 |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
2 ms |
3160 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
2 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 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 |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
2 ms |
3160 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
2 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
4 ms |
12124 KB |
Output is correct |
15 |
Correct |
2 ms |
8540 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
4 ms |
12380 KB |
Output is correct |
19 |
Correct |
4 ms |
12380 KB |
Output is correct |
20 |
Correct |
4 ms |
12380 KB |
Output is correct |
21 |
Correct |
4 ms |
12380 KB |
Output is correct |
22 |
Correct |
4 ms |
12380 KB |
Output is correct |
23 |
Correct |
4 ms |
12380 KB |
Output is correct |
24 |
Correct |
4 ms |
12376 KB |
Output is correct |
25 |
Correct |
4 ms |
12380 KB |
Output is correct |
26 |
Correct |
4 ms |
12380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 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 |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
2 ms |
3160 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
2 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
4 ms |
12124 KB |
Output is correct |
15 |
Correct |
2 ms |
8540 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
4 ms |
12380 KB |
Output is correct |
19 |
Correct |
4 ms |
12380 KB |
Output is correct |
20 |
Correct |
4 ms |
12380 KB |
Output is correct |
21 |
Correct |
4 ms |
12380 KB |
Output is correct |
22 |
Correct |
4 ms |
12380 KB |
Output is correct |
23 |
Correct |
4 ms |
12380 KB |
Output is correct |
24 |
Correct |
4 ms |
12376 KB |
Output is correct |
25 |
Correct |
4 ms |
12380 KB |
Output is correct |
26 |
Correct |
4 ms |
12380 KB |
Output is correct |
27 |
Correct |
71 ms |
79684 KB |
Output is correct |
28 |
Correct |
9 ms |
44888 KB |
Output is correct |
29 |
Correct |
5 ms |
8796 KB |
Output is correct |
30 |
Correct |
1 ms |
2652 KB |
Output is correct |
31 |
Correct |
44 ms |
67696 KB |
Output is correct |
32 |
Correct |
47 ms |
79956 KB |
Output is correct |
33 |
Correct |
45 ms |
79512 KB |
Output is correct |
34 |
Correct |
51 ms |
78164 KB |
Output is correct |
35 |
Correct |
47 ms |
79672 KB |
Output is correct |
36 |
Correct |
45 ms |
79524 KB |
Output is correct |
37 |
Correct |
64 ms |
79712 KB |
Output is correct |
38 |
Correct |
37 ms |
67676 KB |
Output is correct |
39 |
Correct |
35 ms |
67412 KB |
Output is correct |