#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int n,m;
char a[3002][3002];
int jewel[3002][3002];
int orb[3002][3002];
int ingot[3002][3002];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> m;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
cin >> a[i][j];
}
}
memset(jewel,0,sizeof(jewel));
memset(orb,0,sizeof(orb));
memset(ingot,0,sizeof(ingot));
//cout << "jewel: " << jewel[1][5] << endl;
for (int i=1; i<=n; i++) {
for (int j=m; j>=1; j--) {
if (a[i][j]=='J') {
//cout << i << " " << j << endl;
jewel[i][j]=jewel[i][j+1]+1;
} else {
jewel[i][j]=jewel[i][j+1];
}
}
}
for (int i=1; i<=n; i++) {
for (int j=m; j>=1; j--) {
if (a[i][j]=='O') {
orb[i][j]=orb[i][j+1]+1;
} else {
orb[i][j]=orb[i][j+1];
}
}
}
for (int j=1; j<=m; j++) {
for (int i=n; i>=1; i--) {
if (a[i][j]=='I') {
ingot[i][j]=ingot[i+1][j]+1;
} else {
ingot[i][j]=ingot[i+1][j];
}
}
}
// for (int i=1; i<=n; i++) {
// for (int j=1; j<=m; j++) {
// cout << jewel[i][j] << " ";
// }
// cout << endl;
// }
// cout << endl;
// for (int i=1; i<=n; i++) {
// for (int j=1; j<=m; j++) {
// cout << orb[i][j] << " ";
// }
// cout << endl;
// }
// cout << endl;
// for (int i=1; i<=n; i++) {
// for (int j=1; j<=m; j++) {
// cout << ingot[i][j] << " ";
// }
// cout << endl;
// }
// cout << endl;
// //cout << orb[2][2] << " " << ingot[3][1];
int ans=0;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
if (a[i][j]=='J') {
// cout << i << " " << j << endl;
// cout << orb[i][j+1] << " " << ingot[i+1][j] << endl;
// cout << endl;
ans+=(orb[i][j+1]*ingot[i+1][j]);
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
106112 KB |
Output is correct |
2 |
Correct |
36 ms |
106036 KB |
Output is correct |
3 |
Correct |
37 ms |
106060 KB |
Output is correct |
4 |
Correct |
36 ms |
106068 KB |
Output is correct |
5 |
Correct |
36 ms |
106352 KB |
Output is correct |
6 |
Correct |
36 ms |
106392 KB |
Output is correct |
7 |
Correct |
36 ms |
106340 KB |
Output is correct |
8 |
Correct |
37 ms |
106352 KB |
Output is correct |
9 |
Correct |
39 ms |
106312 KB |
Output is correct |
10 |
Correct |
37 ms |
106376 KB |
Output is correct |
11 |
Correct |
37 ms |
106316 KB |
Output is correct |
12 |
Correct |
37 ms |
106332 KB |
Output is correct |
13 |
Correct |
37 ms |
106316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
106112 KB |
Output is correct |
2 |
Correct |
36 ms |
106036 KB |
Output is correct |
3 |
Correct |
37 ms |
106060 KB |
Output is correct |
4 |
Correct |
36 ms |
106068 KB |
Output is correct |
5 |
Correct |
36 ms |
106352 KB |
Output is correct |
6 |
Correct |
36 ms |
106392 KB |
Output is correct |
7 |
Correct |
36 ms |
106340 KB |
Output is correct |
8 |
Correct |
37 ms |
106352 KB |
Output is correct |
9 |
Correct |
39 ms |
106312 KB |
Output is correct |
10 |
Correct |
37 ms |
106376 KB |
Output is correct |
11 |
Correct |
37 ms |
106316 KB |
Output is correct |
12 |
Correct |
37 ms |
106332 KB |
Output is correct |
13 |
Correct |
37 ms |
106316 KB |
Output is correct |
14 |
Correct |
43 ms |
107756 KB |
Output is correct |
15 |
Correct |
38 ms |
107332 KB |
Output is correct |
16 |
Correct |
40 ms |
106892 KB |
Output is correct |
17 |
Correct |
42 ms |
106052 KB |
Output is correct |
18 |
Correct |
44 ms |
107724 KB |
Output is correct |
19 |
Correct |
42 ms |
107820 KB |
Output is correct |
20 |
Incorrect |
52 ms |
107684 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
106112 KB |
Output is correct |
2 |
Correct |
36 ms |
106036 KB |
Output is correct |
3 |
Correct |
37 ms |
106060 KB |
Output is correct |
4 |
Correct |
36 ms |
106068 KB |
Output is correct |
5 |
Correct |
36 ms |
106352 KB |
Output is correct |
6 |
Correct |
36 ms |
106392 KB |
Output is correct |
7 |
Correct |
36 ms |
106340 KB |
Output is correct |
8 |
Correct |
37 ms |
106352 KB |
Output is correct |
9 |
Correct |
39 ms |
106312 KB |
Output is correct |
10 |
Correct |
37 ms |
106376 KB |
Output is correct |
11 |
Correct |
37 ms |
106316 KB |
Output is correct |
12 |
Correct |
37 ms |
106332 KB |
Output is correct |
13 |
Correct |
37 ms |
106316 KB |
Output is correct |
14 |
Correct |
43 ms |
107756 KB |
Output is correct |
15 |
Correct |
38 ms |
107332 KB |
Output is correct |
16 |
Correct |
40 ms |
106892 KB |
Output is correct |
17 |
Correct |
42 ms |
106052 KB |
Output is correct |
18 |
Correct |
44 ms |
107724 KB |
Output is correct |
19 |
Correct |
42 ms |
107820 KB |
Output is correct |
20 |
Incorrect |
52 ms |
107684 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |