#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 3005;
int n, m, cnti[N], cntRight[N][N], cntDown[N][N];
char a[N][N];
signed main() {
#ifdef BLU
in("blu.inp");
#endif
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m;
fw (i, 0, n) fw (j, 0, m) cin >> a[i][j];
fw (i, 0, n) fw (j, 0, m) {
if (a[i][j] == 'I') cnti[j]++;
}
fw (i, 0, n) {
int rowCntO = 0;
fw (j, 0, m) {
if (a[i][j] == 'O') rowCntO++;
}
fw (j, 0, m) {
if (a[i][j] == 'O') rowCntO--;
else if (a[i][j] == 'J') {
cntRight[i][j] = rowCntO;
}
}
fw (j, 0, m) {
if (a[i][j] == 'I') cnti[j]--;
if (a[i][j] == 'J') cntDown[i][j] = cnti[j];
}
}
long long ans = 0;
fw (i, 0, n) {
fw (j, 0, m) {
if (a[i][j] == 'J') ans += 1ll * cntDown[i][j] * cntRight[i][j];
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
4 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
4 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
4 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
4 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
16 ms |
7544 KB |
Output is correct |
15 |
Correct |
5 ms |
4728 KB |
Output is correct |
16 |
Correct |
7 ms |
3836 KB |
Output is correct |
17 |
Correct |
2 ms |
552 KB |
Output is correct |
18 |
Correct |
19 ms |
8056 KB |
Output is correct |
19 |
Correct |
12 ms |
7032 KB |
Output is correct |
20 |
Correct |
7 ms |
6648 KB |
Output is correct |
21 |
Correct |
21 ms |
8028 KB |
Output is correct |
22 |
Correct |
12 ms |
7288 KB |
Output is correct |
23 |
Correct |
11 ms |
6648 KB |
Output is correct |
24 |
Correct |
17 ms |
8056 KB |
Output is correct |
25 |
Correct |
12 ms |
7032 KB |
Output is correct |
26 |
Correct |
13 ms |
6648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
4 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
4 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
16 ms |
7544 KB |
Output is correct |
15 |
Correct |
5 ms |
4728 KB |
Output is correct |
16 |
Correct |
7 ms |
3836 KB |
Output is correct |
17 |
Correct |
2 ms |
552 KB |
Output is correct |
18 |
Correct |
19 ms |
8056 KB |
Output is correct |
19 |
Correct |
12 ms |
7032 KB |
Output is correct |
20 |
Correct |
7 ms |
6648 KB |
Output is correct |
21 |
Correct |
21 ms |
8028 KB |
Output is correct |
22 |
Correct |
12 ms |
7288 KB |
Output is correct |
23 |
Correct |
11 ms |
6648 KB |
Output is correct |
24 |
Correct |
17 ms |
8056 KB |
Output is correct |
25 |
Correct |
12 ms |
7032 KB |
Output is correct |
26 |
Correct |
13 ms |
6648 KB |
Output is correct |
27 |
Correct |
420 ms |
88184 KB |
Output is correct |
28 |
Correct |
21 ms |
24696 KB |
Output is correct |
29 |
Correct |
18 ms |
5368 KB |
Output is correct |
30 |
Correct |
3 ms |
632 KB |
Output is correct |
31 |
Correct |
301 ms |
72700 KB |
Output is correct |
32 |
Correct |
276 ms |
74488 KB |
Output is correct |
33 |
Correct |
215 ms |
65248 KB |
Output is correct |
34 |
Correct |
358 ms |
84260 KB |
Output is correct |
35 |
Correct |
252 ms |
78072 KB |
Output is correct |
36 |
Correct |
213 ms |
65348 KB |
Output is correct |
37 |
Correct |
412 ms |
88568 KB |
Output is correct |
38 |
Correct |
173 ms |
58288 KB |
Output is correct |
39 |
Correct |
153 ms |
50092 KB |
Output is correct |