#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll h,w;
cin>>h>>w;
ll a[h][w];
string s[h];
for(ll i=0;i<h;i++){
cin>>s[i];
}
for(ll i=0;i<h;i++){
ll cur=0;
for(ll j=w-1;j>=0;j--){
if(s[i][j]=='O'){
cur++;
}
a[i][j]=cur;
}
}
ll ans=0;
for(ll j=0;j<w;j++){
ll cur=0;
for(ll i=h-1;i>=0;i--){
if(s[i][j]=='I'){
cur++;
}
if(s[i][j]=='J'){
ans+=cur*a[i][j];
}
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
464 KB |
Output is correct |
11 |
Correct |
0 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
464 KB |
Output is correct |
11 |
Correct |
0 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
2140 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
1624 KB |
Output is correct |
17 |
Correct |
0 ms |
600 KB |
Output is correct |
18 |
Correct |
4 ms |
2908 KB |
Output is correct |
19 |
Correct |
2 ms |
2652 KB |
Output is correct |
20 |
Correct |
2 ms |
2652 KB |
Output is correct |
21 |
Correct |
4 ms |
2932 KB |
Output is correct |
22 |
Correct |
2 ms |
2904 KB |
Output is correct |
23 |
Correct |
2 ms |
2744 KB |
Output is correct |
24 |
Correct |
3 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2704 KB |
Output is correct |
26 |
Correct |
2 ms |
2868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
464 KB |
Output is correct |
11 |
Correct |
0 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
2140 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
1624 KB |
Output is correct |
17 |
Correct |
0 ms |
600 KB |
Output is correct |
18 |
Correct |
4 ms |
2908 KB |
Output is correct |
19 |
Correct |
2 ms |
2652 KB |
Output is correct |
20 |
Correct |
2 ms |
2652 KB |
Output is correct |
21 |
Correct |
4 ms |
2932 KB |
Output is correct |
22 |
Correct |
2 ms |
2904 KB |
Output is correct |
23 |
Correct |
2 ms |
2744 KB |
Output is correct |
24 |
Correct |
3 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2704 KB |
Output is correct |
26 |
Correct |
2 ms |
2868 KB |
Output is correct |
27 |
Correct |
179 ms |
84572 KB |
Output is correct |
28 |
Correct |
1 ms |
600 KB |
Output is correct |
29 |
Correct |
6 ms |
6684 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
119 ms |
62188 KB |
Output is correct |
32 |
Correct |
106 ms |
88704 KB |
Output is correct |
33 |
Correct |
119 ms |
89072 KB |
Output is correct |
34 |
Correct |
143 ms |
72020 KB |
Output is correct |
35 |
Correct |
121 ms |
88700 KB |
Output is correct |
36 |
Correct |
127 ms |
88960 KB |
Output is correct |
37 |
Correct |
185 ms |
89432 KB |
Output is correct |
38 |
Correct |
61 ms |
61520 KB |
Output is correct |
39 |
Correct |
71 ms |
61944 KB |
Output is correct |