#include <iostream>
#define int long long
using namespace std;
char a[3005][3005];
int ko[3005][3005];
int ki[3005][3005];
int32_t main()
{
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = n-1; i >= 0; i--)
for (int j = 0; j < m; j++)
ki[i][j] = ki[i+1][j]+(a[i][j] == 'I');
for (int j = m-1; j >= 0; j--)
for (int i = 0; i < n; i++)
ko[i][j] = ko[i][j+1]+(a[i][j] == 'O');
int rez = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (a[i][j] == 'J')
rez += ko[i][j]*ki[i][j];
cout << rez << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
352 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 |
1372 KB |
Output is correct |
8 |
Correct |
2 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1624 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 |
2 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
352 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 |
1372 KB |
Output is correct |
8 |
Correct |
2 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1624 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 |
2 ms |
1372 KB |
Output is correct |
14 |
Correct |
10 ms |
9052 KB |
Output is correct |
15 |
Correct |
2 ms |
4956 KB |
Output is correct |
16 |
Correct |
7 ms |
5320 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
9 ms |
9868 KB |
Output is correct |
19 |
Correct |
9 ms |
9876 KB |
Output is correct |
20 |
Correct |
8 ms |
9820 KB |
Output is correct |
21 |
Correct |
9 ms |
10076 KB |
Output is correct |
22 |
Correct |
9 ms |
9924 KB |
Output is correct |
23 |
Correct |
8 ms |
9912 KB |
Output is correct |
24 |
Correct |
10 ms |
10024 KB |
Output is correct |
25 |
Correct |
9 ms |
9820 KB |
Output is correct |
26 |
Correct |
8 ms |
9816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
352 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 |
1372 KB |
Output is correct |
8 |
Correct |
2 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1624 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 |
2 ms |
1372 KB |
Output is correct |
14 |
Correct |
10 ms |
9052 KB |
Output is correct |
15 |
Correct |
2 ms |
4956 KB |
Output is correct |
16 |
Correct |
7 ms |
5320 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
9 ms |
9868 KB |
Output is correct |
19 |
Correct |
9 ms |
9876 KB |
Output is correct |
20 |
Correct |
8 ms |
9820 KB |
Output is correct |
21 |
Correct |
9 ms |
10076 KB |
Output is correct |
22 |
Correct |
9 ms |
9924 KB |
Output is correct |
23 |
Correct |
8 ms |
9912 KB |
Output is correct |
24 |
Correct |
10 ms |
10024 KB |
Output is correct |
25 |
Correct |
9 ms |
9820 KB |
Output is correct |
26 |
Correct |
8 ms |
9816 KB |
Output is correct |
27 |
Correct |
359 ms |
158480 KB |
Output is correct |
28 |
Correct |
13 ms |
26456 KB |
Output is correct |
29 |
Correct |
17 ms |
13916 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
282 ms |
131504 KB |
Output is correct |
32 |
Correct |
370 ms |
158908 KB |
Output is correct |
33 |
Correct |
338 ms |
158580 KB |
Output is correct |
34 |
Correct |
311 ms |
152424 KB |
Output is correct |
35 |
Correct |
339 ms |
158892 KB |
Output is correct |
36 |
Correct |
325 ms |
158476 KB |
Output is correct |
37 |
Correct |
371 ms |
159056 KB |
Output is correct |
38 |
Correct |
214 ms |
130900 KB |
Output is correct |
39 |
Correct |
220 ms |
130976 KB |
Output is correct |