#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define N 3010
char a[N][N];
int ans,cnt[2][N];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,m,i,j;
cin>>n>>m;
for(i=0;i<n;i++) for(j=0;j<m;j++)
cin>>a[i][j];
for(i=n-1;i>=0;i--) for(j=m-1;j>=0;j--){
if(a[i][j]=='J') ans+=cnt[0][i]*cnt[1][j];
if(a[i][j]=='O') cnt[0][i]++;
if(a[i][j]=='I') cnt[1][j]++;
}
cout<<ans<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
5 ms |
1792 KB |
Output is correct |
15 |
Correct |
1 ms |
1484 KB |
Output is correct |
16 |
Correct |
3 ms |
1096 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
6 ms |
1740 KB |
Output is correct |
19 |
Correct |
6 ms |
1740 KB |
Output is correct |
20 |
Correct |
4 ms |
1676 KB |
Output is correct |
21 |
Correct |
6 ms |
1740 KB |
Output is correct |
22 |
Correct |
4 ms |
1740 KB |
Output is correct |
23 |
Correct |
4 ms |
1740 KB |
Output is correct |
24 |
Correct |
6 ms |
1740 KB |
Output is correct |
25 |
Correct |
4 ms |
1740 KB |
Output is correct |
26 |
Correct |
5 ms |
1664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
5 ms |
1792 KB |
Output is correct |
15 |
Correct |
1 ms |
1484 KB |
Output is correct |
16 |
Correct |
3 ms |
1096 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
6 ms |
1740 KB |
Output is correct |
19 |
Correct |
6 ms |
1740 KB |
Output is correct |
20 |
Correct |
4 ms |
1676 KB |
Output is correct |
21 |
Correct |
6 ms |
1740 KB |
Output is correct |
22 |
Correct |
4 ms |
1740 KB |
Output is correct |
23 |
Correct |
4 ms |
1740 KB |
Output is correct |
24 |
Correct |
6 ms |
1740 KB |
Output is correct |
25 |
Correct |
4 ms |
1740 KB |
Output is correct |
26 |
Correct |
5 ms |
1664 KB |
Output is correct |
27 |
Correct |
160 ms |
9236 KB |
Output is correct |
28 |
Correct |
4 ms |
7116 KB |
Output is correct |
29 |
Correct |
13 ms |
1100 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
118 ms |
7624 KB |
Output is correct |
32 |
Correct |
125 ms |
9156 KB |
Output is correct |
33 |
Correct |
126 ms |
9036 KB |
Output is correct |
34 |
Correct |
135 ms |
8888 KB |
Output is correct |
35 |
Correct |
128 ms |
9184 KB |
Output is correct |
36 |
Correct |
121 ms |
9040 KB |
Output is correct |
37 |
Correct |
164 ms |
9156 KB |
Output is correct |
38 |
Correct |
91 ms |
7624 KB |
Output is correct |
39 |
Correct |
89 ms |
7676 KB |
Output is correct |