#include <bits/stdc++.h>
using namespace std;
inline namespace
{
} // namespace
void solve()
{
int n, m;
cin >> n >> m;
vector<string> a(n);
for (string &s : a)
cin >> s;
vector suff1(n, vector<long>(m + 1, 0)), suff2(m, vector<long>(n + 1, 0));
for (int i = 0; i < n; i++)
{
for (int j = m - 1; j >= 0; j--)
suff1[i][j] = suff1[i][j + 1] + (a[i][j] == 'O');
}
for (int i = 0; i < m; i++)
{
for (int j = n - 1; j >= 0; j--)
suff2[i][j] = suff2[i][j + 1] + (a[j][i] == 'I');
}
long res = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (a[i][j] == 'J')
res += suff1[i][j] * suff2[j][i];
}
}
cout << res << '\n';
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(NULL);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
496 KB |
Output is correct |
12 |
Correct |
0 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
496 KB |
Output is correct |
12 |
Correct |
0 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
3 ms |
3540 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
2516 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
5 ms |
4436 KB |
Output is correct |
19 |
Correct |
4 ms |
4308 KB |
Output is correct |
20 |
Correct |
4 ms |
4436 KB |
Output is correct |
21 |
Correct |
5 ms |
4676 KB |
Output is correct |
22 |
Correct |
5 ms |
4516 KB |
Output is correct |
23 |
Correct |
4 ms |
4692 KB |
Output is correct |
24 |
Correct |
5 ms |
4680 KB |
Output is correct |
25 |
Correct |
4 ms |
4564 KB |
Output is correct |
26 |
Correct |
5 ms |
4684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
496 KB |
Output is correct |
12 |
Correct |
0 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
3 ms |
3540 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
2516 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
5 ms |
4436 KB |
Output is correct |
19 |
Correct |
4 ms |
4308 KB |
Output is correct |
20 |
Correct |
4 ms |
4436 KB |
Output is correct |
21 |
Correct |
5 ms |
4676 KB |
Output is correct |
22 |
Correct |
5 ms |
4516 KB |
Output is correct |
23 |
Correct |
4 ms |
4692 KB |
Output is correct |
24 |
Correct |
5 ms |
4680 KB |
Output is correct |
25 |
Correct |
4 ms |
4564 KB |
Output is correct |
26 |
Correct |
5 ms |
4684 KB |
Output is correct |
27 |
Correct |
207 ms |
151196 KB |
Output is correct |
28 |
Correct |
1 ms |
840 KB |
Output is correct |
29 |
Correct |
11 ms |
11860 KB |
Output is correct |
30 |
Correct |
1 ms |
724 KB |
Output is correct |
31 |
Correct |
124 ms |
111188 KB |
Output is correct |
32 |
Correct |
158 ms |
158912 KB |
Output is correct |
33 |
Correct |
164 ms |
159556 KB |
Output is correct |
34 |
Correct |
154 ms |
129040 KB |
Output is correct |
35 |
Correct |
185 ms |
158928 KB |
Output is correct |
36 |
Correct |
165 ms |
159496 KB |
Output is correct |
37 |
Correct |
194 ms |
160096 KB |
Output is correct |
38 |
Correct |
106 ms |
110364 KB |
Output is correct |
39 |
Correct |
110 ms |
110768 KB |
Output is correct |