#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e3 + 5;
int n, m, arr[N][N], row[N][5], col[N][5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char ch;
cin >> ch;
if (ch == 'J') arr[i][j] = 0;
else if (ch == 'O') arr[i][j] = 1;
else arr[i][j] = 2;
}
}
int ans = 0;
for (int i = n; i >= 1; i--) {
for (int j = m; j >= 1; j--) {
if (!arr[i][j]) ans += row[i][1]*col[j][2];
row[i][arr[i][j]]++;
col[j][arr[i][j]]++;
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
1 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
1 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
724 KB |
Output is correct |
14 |
Correct |
6 ms |
3796 KB |
Output is correct |
15 |
Correct |
1 ms |
2004 KB |
Output is correct |
16 |
Correct |
3 ms |
2388 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
7 ms |
4308 KB |
Output is correct |
19 |
Correct |
5 ms |
4180 KB |
Output is correct |
20 |
Correct |
7 ms |
4156 KB |
Output is correct |
21 |
Correct |
10 ms |
4532 KB |
Output is correct |
22 |
Correct |
5 ms |
4436 KB |
Output is correct |
23 |
Correct |
6 ms |
4436 KB |
Output is correct |
24 |
Correct |
10 ms |
4544 KB |
Output is correct |
25 |
Correct |
5 ms |
4436 KB |
Output is correct |
26 |
Correct |
6 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
1 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
724 KB |
Output is correct |
14 |
Correct |
6 ms |
3796 KB |
Output is correct |
15 |
Correct |
1 ms |
2004 KB |
Output is correct |
16 |
Correct |
3 ms |
2388 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
7 ms |
4308 KB |
Output is correct |
19 |
Correct |
5 ms |
4180 KB |
Output is correct |
20 |
Correct |
7 ms |
4156 KB |
Output is correct |
21 |
Correct |
10 ms |
4532 KB |
Output is correct |
22 |
Correct |
5 ms |
4436 KB |
Output is correct |
23 |
Correct |
6 ms |
4436 KB |
Output is correct |
24 |
Correct |
10 ms |
4544 KB |
Output is correct |
25 |
Correct |
5 ms |
4436 KB |
Output is correct |
26 |
Correct |
6 ms |
4440 KB |
Output is correct |
27 |
Correct |
235 ms |
79388 KB |
Output is correct |
28 |
Correct |
4 ms |
9940 KB |
Output is correct |
29 |
Correct |
11 ms |
7124 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
165 ms |
65384 KB |
Output is correct |
32 |
Correct |
170 ms |
79784 KB |
Output is correct |
33 |
Correct |
130 ms |
79576 KB |
Output is correct |
34 |
Correct |
188 ms |
75820 KB |
Output is correct |
35 |
Correct |
165 ms |
79744 KB |
Output is correct |
36 |
Correct |
149 ms |
79556 KB |
Output is correct |
37 |
Correct |
250 ms |
79824 KB |
Output is correct |
38 |
Correct |
100 ms |
64992 KB |
Output is correct |
39 |
Correct |
100 ms |
65316 KB |
Output is correct |