/*input
4 4
JJOO
JJOO
IIJO
IIIJ
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int II[3030][3030];
int OO[3030][3030];
int main()
{
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
string s[n];
for (int i = 0; i < n; i++)
cin >> s[i];
ll ans = 0;
for (int i = n - 1; i >= 0; i--)
{
for (int j = m - 1; j >= 0; j--)
{
OO[i][j] = OO[i][j + 1];
II[i][j] = II[i + 1][j];
ll O = OO[i][j];
ll I = II[i][j];
if (s[i][j] == 'J')
ans += O * I;
OO[i][j] += (s[i][j] == 'O');
II[i][j] += (s[i][j] == 'I');
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1280 KB |
Output is correct |
6 |
Correct |
3 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1152 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
1152 KB |
Output is correct |
11 |
Correct |
3 ms |
1280 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
2 ms |
1152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1280 KB |
Output is correct |
6 |
Correct |
3 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1152 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
1152 KB |
Output is correct |
11 |
Correct |
3 ms |
1280 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
2 ms |
1152 KB |
Output is correct |
14 |
Correct |
8 ms |
6016 KB |
Output is correct |
15 |
Correct |
4 ms |
3712 KB |
Output is correct |
16 |
Correct |
5 ms |
3584 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
8 ms |
6528 KB |
Output is correct |
19 |
Correct |
7 ms |
6408 KB |
Output is correct |
20 |
Correct |
8 ms |
6400 KB |
Output is correct |
21 |
Correct |
8 ms |
6528 KB |
Output is correct |
22 |
Correct |
8 ms |
6528 KB |
Output is correct |
23 |
Correct |
7 ms |
6528 KB |
Output is correct |
24 |
Correct |
8 ms |
6656 KB |
Output is correct |
25 |
Correct |
7 ms |
6528 KB |
Output is correct |
26 |
Correct |
8 ms |
6400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1280 KB |
Output is correct |
6 |
Correct |
3 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1152 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
1152 KB |
Output is correct |
11 |
Correct |
3 ms |
1280 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
2 ms |
1152 KB |
Output is correct |
14 |
Correct |
8 ms |
6016 KB |
Output is correct |
15 |
Correct |
4 ms |
3712 KB |
Output is correct |
16 |
Correct |
5 ms |
3584 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
8 ms |
6528 KB |
Output is correct |
19 |
Correct |
7 ms |
6408 KB |
Output is correct |
20 |
Correct |
8 ms |
6400 KB |
Output is correct |
21 |
Correct |
8 ms |
6528 KB |
Output is correct |
22 |
Correct |
8 ms |
6528 KB |
Output is correct |
23 |
Correct |
7 ms |
6528 KB |
Output is correct |
24 |
Correct |
8 ms |
6656 KB |
Output is correct |
25 |
Correct |
7 ms |
6528 KB |
Output is correct |
26 |
Correct |
8 ms |
6400 KB |
Output is correct |
27 |
Correct |
110 ms |
80636 KB |
Output is correct |
28 |
Correct |
19 ms |
19248 KB |
Output is correct |
29 |
Correct |
10 ms |
7808 KB |
Output is correct |
30 |
Correct |
3 ms |
640 KB |
Output is correct |
31 |
Correct |
110 ms |
71632 KB |
Output is correct |
32 |
Correct |
93 ms |
87160 KB |
Output is correct |
33 |
Correct |
90 ms |
87032 KB |
Output is correct |
34 |
Correct |
108 ms |
82040 KB |
Output is correct |
35 |
Correct |
89 ms |
87324 KB |
Output is correct |
36 |
Correct |
94 ms |
87292 KB |
Output is correct |
37 |
Correct |
118 ms |
87416 KB |
Output is correct |
38 |
Correct |
72 ms |
71588 KB |
Output is correct |
39 |
Correct |
68 ms |
71288 KB |
Output is correct |