#include<bits/stdc++.h>
#define int long long
using namespace std;
const int sz = 3e3 + 9;
char a[sz][sz];
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int h, w;
cin >> h >> w;
map <int, vector <int>> os, is;
int r = 0;
for (int i = 1; i <= h; i ++) {
for (int j = 1; j <= w; j ++) {
cin >> a[i][j];
if ('O' == a[i][j]) {
os[i].push_back(j);
} else if ('I' == a[i][j]) {
is[j].push_back(i);
}
}
}
for (int i = 1; i <= h; i ++) {
for (int j = 1; j <= w; j ++) {
if ('J' == a[i][j]) {
if (!os.count(i) || !is.count(j)) continue;
int oc = os[i].end() - upper_bound(begin(os[i]), end(os[i]), j);
int ic = is[j].end() - upper_bound(begin(is[j]), end(is[j]), i);
r += oc * ic;
}
}
}
cout << r << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
2 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
2 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
25 ms |
4188 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
11 ms |
3664 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
29 ms |
4784 KB |
Output is correct |
19 |
Correct |
12 ms |
4956 KB |
Output is correct |
20 |
Correct |
15 ms |
4124 KB |
Output is correct |
21 |
Correct |
31 ms |
4896 KB |
Output is correct |
22 |
Correct |
19 ms |
4512 KB |
Output is correct |
23 |
Correct |
15 ms |
3928 KB |
Output is correct |
24 |
Correct |
30 ms |
4188 KB |
Output is correct |
25 |
Correct |
12 ms |
4956 KB |
Output is correct |
26 |
Correct |
16 ms |
4124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
2 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
25 ms |
4188 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
11 ms |
3664 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
29 ms |
4784 KB |
Output is correct |
19 |
Correct |
12 ms |
4956 KB |
Output is correct |
20 |
Correct |
15 ms |
4124 KB |
Output is correct |
21 |
Correct |
31 ms |
4896 KB |
Output is correct |
22 |
Correct |
19 ms |
4512 KB |
Output is correct |
23 |
Correct |
15 ms |
3928 KB |
Output is correct |
24 |
Correct |
30 ms |
4188 KB |
Output is correct |
25 |
Correct |
12 ms |
4956 KB |
Output is correct |
26 |
Correct |
16 ms |
4124 KB |
Output is correct |
27 |
Execution timed out |
1036 ms |
69444 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |