#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define sc second
#define pb push_back
#define in insert
ll p[3001][3001], d[3001][3001];
int32_t main () {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n , m; cin>>n>>m;
string s[n + 1];
for (int i = 1; i <= n; i++)
cin>>s[i];
for (int i = n; i > 0; i--) {
for (int j = m - 1; j >= 0; j--) {
d[i][j] = d[i][j + 1];
p[i][j] = p[i + 1][j];
if (s[i][j] == 'O') d[i][j]++;
if (s[i][j] == 'I') p[i][j]++;
}
}
ll ans = 0;
for (int i = n; i > 0; i--) {
for (int j = m - 1; j >= 0; j--) {
if (s[i][j] == 'J') {
ans += (d[i][j] * p[i][j]);
}
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
6 ms |
7508 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
2 ms |
4564 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
7 ms |
8532 KB |
Output is correct |
19 |
Correct |
6 ms |
8384 KB |
Output is correct |
20 |
Correct |
5 ms |
8276 KB |
Output is correct |
21 |
Correct |
8 ms |
8532 KB |
Output is correct |
22 |
Correct |
5 ms |
8276 KB |
Output is correct |
23 |
Correct |
5 ms |
8276 KB |
Output is correct |
24 |
Correct |
7 ms |
8520 KB |
Output is correct |
25 |
Correct |
5 ms |
8276 KB |
Output is correct |
26 |
Correct |
5 ms |
8276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
6 ms |
7508 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
2 ms |
4564 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
7 ms |
8532 KB |
Output is correct |
19 |
Correct |
6 ms |
8384 KB |
Output is correct |
20 |
Correct |
5 ms |
8276 KB |
Output is correct |
21 |
Correct |
8 ms |
8532 KB |
Output is correct |
22 |
Correct |
5 ms |
8276 KB |
Output is correct |
23 |
Correct |
5 ms |
8276 KB |
Output is correct |
24 |
Correct |
7 ms |
8520 KB |
Output is correct |
25 |
Correct |
5 ms |
8276 KB |
Output is correct |
26 |
Correct |
5 ms |
8276 KB |
Output is correct |
27 |
Runtime error |
24 ms |
19048 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |