#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=3007;
int h,w,ai[N][N],ao[N][N],cnt;
char a[N][N];
int32_t main(){
cin.tie(NULL)->sync_with_stdio(false);
cin>>h>>w;
for (int i=1; i<=h; i++){
string s;
cin>>s;
for (int j=1; j<=w; j++){
a[i][j]=s[j-1];
}
}/*
for (int i=1; i<=h; i++){
for (int j=1; j<=w; j++){
cout<<a[i][j];
}
cout<<'\n';
}*/
for (int i=h; i>0; i--){
for (int j=w; j>0; j--){
if (a[i][j]=='I') ai[i][j]=ai[i+1][j]+1;
else ai[i][j]=ai[i+1][j];
if (a[i][j]=='O') ao[i][j]=ao[i][j+1]+1;
else ao[i][j]=ao[i][j+1];
}
}
for (int i=1; i<=h; i++){
for (int j=1; j<=w; j++){
if(a[i][j]=='J') cnt+=ai[i][j]*ao[i][j];
}
}
cout<<cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1660 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1660 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1368 KB |
Output is correct |
14 |
Correct |
6 ms |
9052 KB |
Output is correct |
15 |
Correct |
2 ms |
5212 KB |
Output is correct |
16 |
Correct |
3 ms |
5468 KB |
Output is correct |
17 |
Correct |
0 ms |
600 KB |
Output is correct |
18 |
Correct |
6 ms |
10072 KB |
Output is correct |
19 |
Correct |
5 ms |
9820 KB |
Output is correct |
20 |
Correct |
5 ms |
9700 KB |
Output is correct |
21 |
Correct |
6 ms |
10096 KB |
Output is correct |
22 |
Correct |
5 ms |
9820 KB |
Output is correct |
23 |
Correct |
5 ms |
9820 KB |
Output is correct |
24 |
Correct |
6 ms |
9920 KB |
Output is correct |
25 |
Correct |
4 ms |
9820 KB |
Output is correct |
26 |
Correct |
4 ms |
9820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1660 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1368 KB |
Output is correct |
14 |
Correct |
6 ms |
9052 KB |
Output is correct |
15 |
Correct |
2 ms |
5212 KB |
Output is correct |
16 |
Correct |
3 ms |
5468 KB |
Output is correct |
17 |
Correct |
0 ms |
600 KB |
Output is correct |
18 |
Correct |
6 ms |
10072 KB |
Output is correct |
19 |
Correct |
5 ms |
9820 KB |
Output is correct |
20 |
Correct |
5 ms |
9700 KB |
Output is correct |
21 |
Correct |
6 ms |
10096 KB |
Output is correct |
22 |
Correct |
5 ms |
9820 KB |
Output is correct |
23 |
Correct |
5 ms |
9820 KB |
Output is correct |
24 |
Correct |
6 ms |
9920 KB |
Output is correct |
25 |
Correct |
4 ms |
9820 KB |
Output is correct |
26 |
Correct |
4 ms |
9820 KB |
Output is correct |
27 |
Correct |
136 ms |
158692 KB |
Output is correct |
28 |
Correct |
11 ms |
26456 KB |
Output is correct |
29 |
Correct |
8 ms |
14016 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
106 ms |
131412 KB |
Output is correct |
32 |
Correct |
93 ms |
159060 KB |
Output is correct |
33 |
Correct |
90 ms |
158692 KB |
Output is correct |
34 |
Correct |
117 ms |
152660 KB |
Output is correct |
35 |
Correct |
92 ms |
159064 KB |
Output is correct |
36 |
Correct |
89 ms |
158800 KB |
Output is correct |
37 |
Correct |
129 ms |
159312 KB |
Output is correct |
38 |
Correct |
79 ms |
130928 KB |
Output is correct |
39 |
Correct |
78 ms |
131120 KB |
Output is correct |