#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a, I = b; i <= I; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }
const int N = 3005;
char a[N][N];
int j_sum[N][N];
signed main() {
IO;
int n, m;
cin >> n >> m;
FOR(i, 1, n)
FOR(j, 1, m)
cin >> a[i][j];
for (int i = 1; i <= n; i++) {
int O_cnt = 0;
for (int j = m; j >= 1; j--) {
if (a[i][j] == 'O')
O_cnt += 1;
else if (a[i][j] == 'J')
j_sum[i][j] = O_cnt;
}
}
int ans = 0;
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++) {
j_sum[i][j] += j_sum[i - 1][j];
if (a[i][j] == 'I')
ans += j_sum[i][j];
}
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2516 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
4572 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2516 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
4572 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
5 ms |
16984 KB |
Output is correct |
15 |
Correct |
2 ms |
12632 KB |
Output is correct |
16 |
Correct |
3 ms |
8792 KB |
Output is correct |
17 |
Correct |
1 ms |
4696 KB |
Output is correct |
18 |
Correct |
7 ms |
16980 KB |
Output is correct |
19 |
Correct |
5 ms |
16988 KB |
Output is correct |
20 |
Correct |
7 ms |
17116 KB |
Output is correct |
21 |
Correct |
7 ms |
16988 KB |
Output is correct |
22 |
Correct |
5 ms |
16988 KB |
Output is correct |
23 |
Correct |
5 ms |
16988 KB |
Output is correct |
24 |
Correct |
6 ms |
17192 KB |
Output is correct |
25 |
Correct |
5 ms |
17156 KB |
Output is correct |
26 |
Correct |
5 ms |
17120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2516 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
4572 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
5 ms |
16984 KB |
Output is correct |
15 |
Correct |
2 ms |
12632 KB |
Output is correct |
16 |
Correct |
3 ms |
8792 KB |
Output is correct |
17 |
Correct |
1 ms |
4696 KB |
Output is correct |
18 |
Correct |
7 ms |
16980 KB |
Output is correct |
19 |
Correct |
5 ms |
16988 KB |
Output is correct |
20 |
Correct |
7 ms |
17116 KB |
Output is correct |
21 |
Correct |
7 ms |
16988 KB |
Output is correct |
22 |
Correct |
5 ms |
16988 KB |
Output is correct |
23 |
Correct |
5 ms |
16988 KB |
Output is correct |
24 |
Correct |
6 ms |
17192 KB |
Output is correct |
25 |
Correct |
5 ms |
17156 KB |
Output is correct |
26 |
Correct |
5 ms |
17120 KB |
Output is correct |
27 |
Correct |
199 ms |
88680 KB |
Output is correct |
28 |
Correct |
7 ms |
60508 KB |
Output is correct |
29 |
Correct |
8 ms |
9308 KB |
Output is correct |
30 |
Correct |
1 ms |
4700 KB |
Output is correct |
31 |
Correct |
143 ms |
74312 KB |
Output is correct |
32 |
Correct |
145 ms |
89164 KB |
Output is correct |
33 |
Correct |
134 ms |
88656 KB |
Output is correct |
34 |
Correct |
151 ms |
86608 KB |
Output is correct |
35 |
Correct |
140 ms |
88772 KB |
Output is correct |
36 |
Correct |
133 ms |
88664 KB |
Output is correct |
37 |
Correct |
179 ms |
88512 KB |
Output is correct |
38 |
Correct |
104 ms |
74564 KB |
Output is correct |
39 |
Correct |
96 ms |
74316 KB |
Output is correct |