#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define exit exit(false)
#define pause system("PAUSE")
//#define here() cerr << "herewego\n";
#define showe(x) cerr << #x << ": " << x << '\n'
#define shows(x) cerr << #x << ": " << x << ", "
#define ioio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
signed main () { ioio();
int n, m;
cin >> n >> m;
char a[n+1][m+1];
int cn[n+1][m+1], ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
cn[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
int O = 0;
for (int j = m; j >= 1; j--) {
if (a[i][j] == 'J') {
cn[i][j] = O;
}
else if (a[i][j] == 'O') {
O++;
}
}
}
for (int j = 1; j <= m; j++) {
int I = 0;
for (int i = n; i >= 1; i--) {
if (a[i][j] == 'J') {
ans += (I * cn[i][j]);
}
else if (a[i][j] == 'I') {
I++;
}
}
}
cout << ans;
// cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 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 |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 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 |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
7 ms |
2176 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
4 ms |
1644 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
8 ms |
2796 KB |
Output is correct |
19 |
Correct |
6 ms |
2668 KB |
Output is correct |
20 |
Correct |
6 ms |
2668 KB |
Output is correct |
21 |
Correct |
9 ms |
2796 KB |
Output is correct |
22 |
Correct |
6 ms |
2668 KB |
Output is correct |
23 |
Correct |
7 ms |
2668 KB |
Output is correct |
24 |
Correct |
9 ms |
2796 KB |
Output is correct |
25 |
Correct |
6 ms |
2668 KB |
Output is correct |
26 |
Correct |
6 ms |
2668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 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 |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
7 ms |
2176 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
4 ms |
1644 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
8 ms |
2796 KB |
Output is correct |
19 |
Correct |
6 ms |
2668 KB |
Output is correct |
20 |
Correct |
6 ms |
2668 KB |
Output is correct |
21 |
Correct |
9 ms |
2796 KB |
Output is correct |
22 |
Correct |
6 ms |
2668 KB |
Output is correct |
23 |
Correct |
7 ms |
2668 KB |
Output is correct |
24 |
Correct |
9 ms |
2796 KB |
Output is correct |
25 |
Correct |
6 ms |
2668 KB |
Output is correct |
26 |
Correct |
6 ms |
2668 KB |
Output is correct |
27 |
Correct |
341 ms |
83564 KB |
Output is correct |
28 |
Correct |
1 ms |
620 KB |
Output is correct |
29 |
Correct |
16 ms |
6636 KB |
Output is correct |
30 |
Correct |
1 ms |
620 KB |
Output is correct |
31 |
Correct |
248 ms |
61688 KB |
Output is correct |
32 |
Correct |
285 ms |
87916 KB |
Output is correct |
33 |
Correct |
304 ms |
88172 KB |
Output is correct |
34 |
Correct |
308 ms |
71404 KB |
Output is correct |
35 |
Correct |
317 ms |
87788 KB |
Output is correct |
36 |
Correct |
319 ms |
88236 KB |
Output is correct |
37 |
Correct |
383 ms |
88428 KB |
Output is correct |
38 |
Correct |
181 ms |
61036 KB |
Output is correct |
39 |
Correct |
209 ms |
61420 KB |
Output is correct |