#include <bits/stdc++.h>
#define ll long long
#define nikah ios_base::sync_with_stdio(0); cin.tie(0);
const ll maxn = 3e3+7;
using namespace std;
ll t,n,m;
char a[maxn][maxn];
ll pref1[maxn][maxn], pref2[maxn][maxn];
int main () {
nikah
cin>>n>>m;
for (ll i=1; i<=n; i++) {
for (ll j=1; j<=m; j++) {
cin>>a[i][j];
}
}
ll ans = 0;
for (ll i=1; i<=n; i++) {
for (ll j=m; j>=1; j--) {
if (a[i][j] == 'O') pref1[i][j]++;
pref1[i][j] += pref1[i][j+1];
}
}
for (ll j=1; j<=m; j++) {
for (ll i=n; i>=1; i--) {
if (a[i][j] == 'I') pref2[i][j]++;
pref2[i][j] += pref2[i+1][j];
}
}
for (ll i=1; i<=n; i++) {
for (ll j=1; j<=m; j++) {
if (a[i][j] == 'J') {
ans += (pref1[i][j] * pref2[i][j]);
}
}
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
5468 KB |
Output is correct |
6 |
Correct |
1 ms |
5468 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5468 KB |
Output is correct |
9 |
Correct |
1 ms |
5468 KB |
Output is correct |
10 |
Correct |
2 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
5468 KB |
Output is correct |
12 |
Correct |
1 ms |
5468 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
5468 KB |
Output is correct |
6 |
Correct |
1 ms |
5468 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5468 KB |
Output is correct |
9 |
Correct |
1 ms |
5468 KB |
Output is correct |
10 |
Correct |
2 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
5468 KB |
Output is correct |
12 |
Correct |
1 ms |
5468 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
14 |
Correct |
9 ms |
11356 KB |
Output is correct |
15 |
Correct |
2 ms |
8028 KB |
Output is correct |
16 |
Correct |
5 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
8 ms |
12468 KB |
Output is correct |
19 |
Correct |
9 ms |
12164 KB |
Output is correct |
20 |
Correct |
7 ms |
12124 KB |
Output is correct |
21 |
Correct |
7 ms |
12380 KB |
Output is correct |
22 |
Correct |
7 ms |
12252 KB |
Output is correct |
23 |
Correct |
8 ms |
12244 KB |
Output is correct |
24 |
Correct |
9 ms |
12380 KB |
Output is correct |
25 |
Correct |
6 ms |
12220 KB |
Output is correct |
26 |
Correct |
7 ms |
12124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
5468 KB |
Output is correct |
6 |
Correct |
1 ms |
5468 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5468 KB |
Output is correct |
9 |
Correct |
1 ms |
5468 KB |
Output is correct |
10 |
Correct |
2 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
5468 KB |
Output is correct |
12 |
Correct |
1 ms |
5468 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
14 |
Correct |
9 ms |
11356 KB |
Output is correct |
15 |
Correct |
2 ms |
8028 KB |
Output is correct |
16 |
Correct |
5 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
8 ms |
12468 KB |
Output is correct |
19 |
Correct |
9 ms |
12164 KB |
Output is correct |
20 |
Correct |
7 ms |
12124 KB |
Output is correct |
21 |
Correct |
7 ms |
12380 KB |
Output is correct |
22 |
Correct |
7 ms |
12252 KB |
Output is correct |
23 |
Correct |
8 ms |
12244 KB |
Output is correct |
24 |
Correct |
9 ms |
12380 KB |
Output is correct |
25 |
Correct |
6 ms |
12220 KB |
Output is correct |
26 |
Correct |
7 ms |
12124 KB |
Output is correct |
27 |
Correct |
212 ms |
150468 KB |
Output is correct |
28 |
Correct |
9 ms |
29788 KB |
Output is correct |
29 |
Correct |
13 ms |
16728 KB |
Output is correct |
30 |
Correct |
1 ms |
2908 KB |
Output is correct |
31 |
Correct |
153 ms |
128200 KB |
Output is correct |
32 |
Correct |
192 ms |
150608 KB |
Output is correct |
33 |
Correct |
202 ms |
150356 KB |
Output is correct |
34 |
Correct |
190 ms |
147296 KB |
Output is correct |
35 |
Correct |
206 ms |
150624 KB |
Output is correct |
36 |
Correct |
201 ms |
150356 KB |
Output is correct |
37 |
Correct |
254 ms |
150608 KB |
Output is correct |
38 |
Correct |
137 ms |
127700 KB |
Output is correct |
39 |
Correct |
134 ms |
127688 KB |
Output is correct |