#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; ++i) {
cin >> s[i];
}
vector<vector<int>> r(h, vector<int>(w, 0));
for (int i = 0; i < h; ++i) {
int cnt = 0;
for (int j = w - 1; j >= 0; --j) {
if (s[i][j] == 'O') ++cnt;
r[i][j] = cnt;
}
}
vector<vector<int>> d(h, vector<int>(w, 0));
for (int j = 0; j < w; ++j) {
int cnt = 0;
for (int i = h - 1; i >= 0; --i) {
if (s[i][j] == 'I') ++cnt;
d[i][j] = cnt;
}
}
ll ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (s[i][j] == 'J') ans += r[i][j] * d[i][j];
}
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
492 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
492 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
492 KB |
Output is correct |
14 |
Correct |
4 ms |
2284 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
1644 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
5 ms |
2796 KB |
Output is correct |
19 |
Correct |
4 ms |
2796 KB |
Output is correct |
20 |
Correct |
4 ms |
2924 KB |
Output is correct |
21 |
Correct |
5 ms |
2796 KB |
Output is correct |
22 |
Correct |
4 ms |
2796 KB |
Output is correct |
23 |
Correct |
4 ms |
2796 KB |
Output is correct |
24 |
Correct |
6 ms |
2924 KB |
Output is correct |
25 |
Correct |
4 ms |
2796 KB |
Output is correct |
26 |
Correct |
4 ms |
2796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
492 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
492 KB |
Output is correct |
14 |
Correct |
4 ms |
2284 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
1644 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
5 ms |
2796 KB |
Output is correct |
19 |
Correct |
4 ms |
2796 KB |
Output is correct |
20 |
Correct |
4 ms |
2924 KB |
Output is correct |
21 |
Correct |
5 ms |
2796 KB |
Output is correct |
22 |
Correct |
4 ms |
2796 KB |
Output is correct |
23 |
Correct |
4 ms |
2796 KB |
Output is correct |
24 |
Correct |
6 ms |
2924 KB |
Output is correct |
25 |
Correct |
4 ms |
2796 KB |
Output is correct |
26 |
Correct |
4 ms |
2796 KB |
Output is correct |
27 |
Correct |
279 ms |
84700 KB |
Output is correct |
28 |
Correct |
2 ms |
876 KB |
Output is correct |
29 |
Correct |
11 ms |
6804 KB |
Output is correct |
30 |
Correct |
1 ms |
620 KB |
Output is correct |
31 |
Correct |
208 ms |
62444 KB |
Output is correct |
32 |
Correct |
270 ms |
89068 KB |
Output is correct |
33 |
Correct |
268 ms |
89452 KB |
Output is correct |
34 |
Correct |
224 ms |
72172 KB |
Output is correct |
35 |
Correct |
269 ms |
89196 KB |
Output is correct |
36 |
Correct |
262 ms |
89448 KB |
Output is correct |
37 |
Correct |
301 ms |
89836 KB |
Output is correct |
38 |
Correct |
171 ms |
61932 KB |
Output is correct |
39 |
Correct |
168 ms |
62060 KB |
Output is correct |