#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
int32_t main(){
int n,m;
cin>>n>>m;
char arr[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)cin>>arr[i][j];
}
int a[n+5][m+5];
memset(a,0,sizeof(a));
for(int i=0;i<n;i++){
for(int j=m-1;j>=0;j--){
a[i][j]=a[i][j+1]+(arr[i][j]=='O');
}
}
int ans=0;
for(int j=0;j<m;j++){
int x=0;
for(int i=n-1;i>=0;i--){
x+=(arr[i][j]=='I');
if(arr[i][j]=='J')ans+=(x*a[i][j]);
}
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
12 ms |
2132 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
9 ms |
1592 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
16 ms |
2772 KB |
Output is correct |
19 |
Correct |
15 ms |
2644 KB |
Output is correct |
20 |
Correct |
16 ms |
2712 KB |
Output is correct |
21 |
Correct |
16 ms |
2772 KB |
Output is correct |
22 |
Correct |
14 ms |
2676 KB |
Output is correct |
23 |
Correct |
16 ms |
2672 KB |
Output is correct |
24 |
Correct |
16 ms |
2772 KB |
Output is correct |
25 |
Correct |
15 ms |
2636 KB |
Output is correct |
26 |
Correct |
15 ms |
2728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
12 ms |
2132 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
9 ms |
1592 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
16 ms |
2772 KB |
Output is correct |
19 |
Correct |
15 ms |
2644 KB |
Output is correct |
20 |
Correct |
16 ms |
2712 KB |
Output is correct |
21 |
Correct |
16 ms |
2772 KB |
Output is correct |
22 |
Correct |
14 ms |
2676 KB |
Output is correct |
23 |
Correct |
16 ms |
2672 KB |
Output is correct |
24 |
Correct |
16 ms |
2772 KB |
Output is correct |
25 |
Correct |
15 ms |
2636 KB |
Output is correct |
26 |
Correct |
15 ms |
2728 KB |
Output is correct |
27 |
Correct |
583 ms |
77980 KB |
Output is correct |
28 |
Correct |
2 ms |
568 KB |
Output is correct |
29 |
Correct |
40 ms |
6644 KB |
Output is correct |
30 |
Correct |
2 ms |
596 KB |
Output is correct |
31 |
Correct |
420 ms |
58172 KB |
Output is correct |
32 |
Correct |
574 ms |
84300 KB |
Output is correct |
33 |
Correct |
589 ms |
84552 KB |
Output is correct |
34 |
Correct |
481 ms |
67972 KB |
Output is correct |
35 |
Correct |
589 ms |
84436 KB |
Output is correct |
36 |
Correct |
592 ms |
84712 KB |
Output is correct |
37 |
Correct |
622 ms |
84812 KB |
Output is correct |
38 |
Correct |
390 ms |
57592 KB |
Output is correct |
39 |
Correct |
406 ms |
58008 KB |
Output is correct |