#include"bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991
const int maxn = 3001;
char g[maxn][maxn];
int suffO[maxn][maxn], suffI[maxn][maxn];
signed main () {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
for (int i = 0 ; i < n ; i++) {
for (int j = 0 ; j < m ; j++) cin >> g[i][j];
}
int ans = 0;
for (int i = n - 1 ; i >= 0 ; i--) {
for (int j = m - 1 ; j >= 0 ; j--) {
if (i + 1 < n) suffO[i][j] = suffO[i + 1][j];
suffO[i][j] += g[i][j] == 'I';
if (j + 1 < m) suffI[i][j] = suffI[i][j + 1];
suffI[i][j] += g[i][j] == 'O';
if (g[i][j] == 'J') {
ans += suffO[i][j] * suffI[i][j];
}
}
}
cout << ans << endl;
}
Compilation message
joi2019_ho_t1.cpp:14:1: warning: multi-line comment [-Wcomment]
14 | //\
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
8 ms |
9012 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
6 ms |
5332 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
8 ms |
9940 KB |
Output is correct |
19 |
Correct |
8 ms |
9812 KB |
Output is correct |
20 |
Correct |
8 ms |
9684 KB |
Output is correct |
21 |
Correct |
9 ms |
9940 KB |
Output is correct |
22 |
Correct |
8 ms |
9812 KB |
Output is correct |
23 |
Correct |
8 ms |
9796 KB |
Output is correct |
24 |
Correct |
8 ms |
9944 KB |
Output is correct |
25 |
Correct |
8 ms |
9812 KB |
Output is correct |
26 |
Correct |
9 ms |
9796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
8 ms |
9012 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
6 ms |
5332 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
8 ms |
9940 KB |
Output is correct |
19 |
Correct |
8 ms |
9812 KB |
Output is correct |
20 |
Correct |
8 ms |
9684 KB |
Output is correct |
21 |
Correct |
9 ms |
9940 KB |
Output is correct |
22 |
Correct |
8 ms |
9812 KB |
Output is correct |
23 |
Correct |
8 ms |
9796 KB |
Output is correct |
24 |
Correct |
8 ms |
9944 KB |
Output is correct |
25 |
Correct |
8 ms |
9812 KB |
Output is correct |
26 |
Correct |
9 ms |
9796 KB |
Output is correct |
27 |
Correct |
197 ms |
158352 KB |
Output is correct |
28 |
Correct |
14 ms |
26292 KB |
Output is correct |
29 |
Correct |
16 ms |
13780 KB |
Output is correct |
30 |
Correct |
2 ms |
728 KB |
Output is correct |
31 |
Correct |
160 ms |
131092 KB |
Output is correct |
32 |
Correct |
200 ms |
158796 KB |
Output is correct |
33 |
Correct |
199 ms |
158272 KB |
Output is correct |
34 |
Correct |
186 ms |
152056 KB |
Output is correct |
35 |
Correct |
197 ms |
158696 KB |
Output is correct |
36 |
Correct |
192 ms |
158216 KB |
Output is correct |
37 |
Correct |
241 ms |
158788 KB |
Output is correct |
38 |
Correct |
140 ms |
130712 KB |
Output is correct |
39 |
Correct |
144 ms |
130640 KB |
Output is correct |