#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define INF INT_MAX
#define st first
#define nd second
using namespace std;
const int N = 3e3 + 10;
int sumi[N][N], sumo[N][N];
char c[N][N];
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
int n, m; cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> c[i][j];
}
}
ll cnt = 0;
for (int i = n; i >= 1; --i) for (int j = m; j >= 1; --j) sumi[i][j] = sumi[i+1][j] + (c[i][j] == 'I');
for (int i = n; i >= 1; --i) for (int j = m; j >= 1; --j) sumo[i][j] = sumo[i][j+1] + (c[i][j] == 'O');
for (int i = n; i >= 1; --i) for (int j = m; j >= 1; --j) if (c[i][j]=='J') cnt += (sumi[i][j]*sumo[i][j]);
cout << cnt << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1496 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1496 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
8 ms |
7640 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
5 ms |
4308 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
9 ms |
7920 KB |
Output is correct |
19 |
Correct |
8 ms |
7884 KB |
Output is correct |
20 |
Correct |
11 ms |
7796 KB |
Output is correct |
21 |
Correct |
9 ms |
7988 KB |
Output is correct |
22 |
Correct |
8 ms |
7892 KB |
Output is correct |
23 |
Correct |
8 ms |
7876 KB |
Output is correct |
24 |
Correct |
9 ms |
8000 KB |
Output is correct |
25 |
Correct |
8 ms |
7892 KB |
Output is correct |
26 |
Correct |
8 ms |
7852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1496 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
8 ms |
7640 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
5 ms |
4308 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
9 ms |
7920 KB |
Output is correct |
19 |
Correct |
8 ms |
7884 KB |
Output is correct |
20 |
Correct |
11 ms |
7796 KB |
Output is correct |
21 |
Correct |
9 ms |
7988 KB |
Output is correct |
22 |
Correct |
8 ms |
7892 KB |
Output is correct |
23 |
Correct |
8 ms |
7876 KB |
Output is correct |
24 |
Correct |
9 ms |
8000 KB |
Output is correct |
25 |
Correct |
8 ms |
7892 KB |
Output is correct |
26 |
Correct |
8 ms |
7852 KB |
Output is correct |
27 |
Correct |
217 ms |
88140 KB |
Output is correct |
28 |
Correct |
12 ms |
26012 KB |
Output is correct |
29 |
Correct |
13 ms |
7784 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
145 ms |
72700 KB |
Output is correct |
32 |
Correct |
191 ms |
88568 KB |
Output is correct |
33 |
Correct |
207 ms |
88224 KB |
Output is correct |
34 |
Correct |
162 ms |
84436 KB |
Output is correct |
35 |
Correct |
181 ms |
88632 KB |
Output is correct |
36 |
Correct |
171 ms |
88220 KB |
Output is correct |
37 |
Correct |
205 ms |
88632 KB |
Output is correct |
38 |
Correct |
134 ms |
72544 KB |
Output is correct |
39 |
Correct |
121 ms |
72348 KB |
Output is correct |