#include <vector>
#include <iostream>
#define int int64_t
using namespace std;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<vector<int>> pref_o(h, vector<int>(w + 1));
vector<vector<int>> pref_i(w, vector<int>(h + 1));
vector<pair<int,int>> js;
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
pref_o[i][j + 1] = pref_o[i][j];
pref_i[j][i + 1] = pref_i[j][i];
char c;
cin >> c;
if (c == 'J') js.push_back({i, j});
else if (c == 'I') pref_i[j][i + 1]++;
else if (c == 'O') pref_o[i][j + 1]++;
}
}
int ans = 0;
for (auto p : js)
{
ans += (pref_i[p.second][h] - pref_i[p.second][p.first])*(pref_o[p.first][w] - pref_o[p.first][p.second]);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
632 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
3 ms |
632 KB |
Output is correct |
11 |
Correct |
3 ms |
632 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
632 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
3 ms |
632 KB |
Output is correct |
11 |
Correct |
3 ms |
632 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
632 KB |
Output is correct |
14 |
Correct |
14 ms |
4728 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
9 ms |
3696 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
20 ms |
6792 KB |
Output is correct |
19 |
Correct |
14 ms |
5108 KB |
Output is correct |
20 |
Correct |
17 ms |
6636 KB |
Output is correct |
21 |
Correct |
19 ms |
6772 KB |
Output is correct |
22 |
Correct |
15 ms |
6636 KB |
Output is correct |
23 |
Correct |
15 ms |
6632 KB |
Output is correct |
24 |
Correct |
19 ms |
6768 KB |
Output is correct |
25 |
Correct |
13 ms |
4980 KB |
Output is correct |
26 |
Correct |
15 ms |
6636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
632 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
3 ms |
632 KB |
Output is correct |
11 |
Correct |
3 ms |
632 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
632 KB |
Output is correct |
14 |
Correct |
14 ms |
4728 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
9 ms |
3696 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
20 ms |
6792 KB |
Output is correct |
19 |
Correct |
14 ms |
5108 KB |
Output is correct |
20 |
Correct |
17 ms |
6636 KB |
Output is correct |
21 |
Correct |
19 ms |
6772 KB |
Output is correct |
22 |
Correct |
15 ms |
6636 KB |
Output is correct |
23 |
Correct |
15 ms |
6632 KB |
Output is correct |
24 |
Correct |
19 ms |
6768 KB |
Output is correct |
25 |
Correct |
13 ms |
4980 KB |
Output is correct |
26 |
Correct |
15 ms |
6636 KB |
Output is correct |
27 |
Correct |
797 ms |
205924 KB |
Output is correct |
28 |
Correct |
4 ms |
1272 KB |
Output is correct |
29 |
Correct |
49 ms |
15460 KB |
Output is correct |
30 |
Correct |
4 ms |
1016 KB |
Output is correct |
31 |
Correct |
563 ms |
137084 KB |
Output is correct |
32 |
Correct |
676 ms |
162988 KB |
Output is correct |
33 |
Correct |
821 ms |
211204 KB |
Output is correct |
34 |
Correct |
695 ms |
186472 KB |
Output is correct |
35 |
Correct |
838 ms |
212888 KB |
Output is correct |
36 |
Correct |
853 ms |
211100 KB |
Output is correct |
37 |
Correct |
879 ms |
212632 KB |
Output is correct |
38 |
Correct |
471 ms |
119288 KB |
Output is correct |
39 |
Correct |
535 ms |
136728 KB |
Output is correct |