#include <bits/stdc++.h>
using namespace std;
#define int long long
int N, M, T;
char F[3005][3005];
vector<int> O[3005], I[3005];
main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N >> M;
for (int i = 1; i <= N; i++)
for (int j = 1; j <= M; j++) {
cin >> F[i][j];
if (F[i][j] == 'O') O[i].push_back(j);
else if (F[i][j] == 'I') I[j].push_back(i);
}
for (int i = 1; i <= N; i++)
for (int j = 1; j <= M; j++)
if (F[i][j] == 'J') {
auto it = upper_bound(O[i].begin(), O[i].end(), j), it2 = upper_bound(I[j].begin(), I[j].end(), i);
T += (O[i].end() - it) * (I[j].end() - it2);
}
cout << T << '\n';
}
Compilation message
joi2019_ho_t1.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
504 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
5 |
Correct |
6 ms |
888 KB |
Output is correct |
6 |
Correct |
5 ms |
888 KB |
Output is correct |
7 |
Correct |
5 ms |
760 KB |
Output is correct |
8 |
Correct |
6 ms |
892 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
760 KB |
Output is correct |
11 |
Correct |
6 ms |
888 KB |
Output is correct |
12 |
Correct |
5 ms |
888 KB |
Output is correct |
13 |
Correct |
5 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
504 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
5 |
Correct |
6 ms |
888 KB |
Output is correct |
6 |
Correct |
5 ms |
888 KB |
Output is correct |
7 |
Correct |
5 ms |
760 KB |
Output is correct |
8 |
Correct |
6 ms |
892 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
760 KB |
Output is correct |
11 |
Correct |
6 ms |
888 KB |
Output is correct |
12 |
Correct |
5 ms |
888 KB |
Output is correct |
13 |
Correct |
5 ms |
888 KB |
Output is correct |
14 |
Correct |
19 ms |
3704 KB |
Output is correct |
15 |
Correct |
6 ms |
1784 KB |
Output is correct |
16 |
Correct |
10 ms |
2296 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Correct |
23 ms |
4344 KB |
Output is correct |
19 |
Correct |
15 ms |
4600 KB |
Output is correct |
20 |
Correct |
13 ms |
3448 KB |
Output is correct |
21 |
Correct |
25 ms |
4448 KB |
Output is correct |
22 |
Correct |
17 ms |
3960 KB |
Output is correct |
23 |
Correct |
13 ms |
3448 KB |
Output is correct |
24 |
Correct |
24 ms |
3836 KB |
Output is correct |
25 |
Correct |
14 ms |
4472 KB |
Output is correct |
26 |
Correct |
12 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
504 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
5 |
Correct |
6 ms |
888 KB |
Output is correct |
6 |
Correct |
5 ms |
888 KB |
Output is correct |
7 |
Correct |
5 ms |
760 KB |
Output is correct |
8 |
Correct |
6 ms |
892 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
760 KB |
Output is correct |
11 |
Correct |
6 ms |
888 KB |
Output is correct |
12 |
Correct |
5 ms |
888 KB |
Output is correct |
13 |
Correct |
5 ms |
888 KB |
Output is correct |
14 |
Correct |
19 ms |
3704 KB |
Output is correct |
15 |
Correct |
6 ms |
1784 KB |
Output is correct |
16 |
Correct |
10 ms |
2296 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Correct |
23 ms |
4344 KB |
Output is correct |
19 |
Correct |
15 ms |
4600 KB |
Output is correct |
20 |
Correct |
13 ms |
3448 KB |
Output is correct |
21 |
Correct |
25 ms |
4448 KB |
Output is correct |
22 |
Correct |
17 ms |
3960 KB |
Output is correct |
23 |
Correct |
13 ms |
3448 KB |
Output is correct |
24 |
Correct |
24 ms |
3836 KB |
Output is correct |
25 |
Correct |
14 ms |
4472 KB |
Output is correct |
26 |
Correct |
12 ms |
3448 KB |
Output is correct |
27 |
Correct |
742 ms |
69752 KB |
Output is correct |
28 |
Correct |
10 ms |
7544 KB |
Output is correct |
29 |
Correct |
27 ms |
6648 KB |
Output is correct |
30 |
Correct |
7 ms |
760 KB |
Output is correct |
31 |
Correct |
546 ms |
51680 KB |
Output is correct |
32 |
Correct |
386 ms |
92536 KB |
Output is correct |
33 |
Correct |
356 ms |
73592 KB |
Output is correct |
34 |
Correct |
662 ms |
57544 KB |
Output is correct |
35 |
Correct |
550 ms |
72488 KB |
Output is correct |
36 |
Correct |
360 ms |
73592 KB |
Output is correct |
37 |
Correct |
880 ms |
77560 KB |
Output is correct |
38 |
Correct |
238 ms |
64120 KB |
Output is correct |
39 |
Correct |
242 ms |
57976 KB |
Output is correct |