#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 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 |
3868 KB |
Output is correct |
15 |
Correct |
1 ms |
2004 KB |
Output is correct |
16 |
Correct |
2 ms |
2412 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 |
4 ms |
4180 KB |
Output is correct |
21 |
Correct |
7 ms |
4308 KB |
Output is correct |
22 |
Correct |
5 ms |
4180 KB |
Output is correct |
23 |
Correct |
5 ms |
4180 KB |
Output is correct |
24 |
Correct |
8 ms |
4340 KB |
Output is correct |
25 |
Correct |
5 ms |
4180 KB |
Output is correct |
26 |
Correct |
4 ms |
4180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 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 |
3868 KB |
Output is correct |
15 |
Correct |
1 ms |
2004 KB |
Output is correct |
16 |
Correct |
2 ms |
2412 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 |
4 ms |
4180 KB |
Output is correct |
21 |
Correct |
7 ms |
4308 KB |
Output is correct |
22 |
Correct |
5 ms |
4180 KB |
Output is correct |
23 |
Correct |
5 ms |
4180 KB |
Output is correct |
24 |
Correct |
8 ms |
4340 KB |
Output is correct |
25 |
Correct |
5 ms |
4180 KB |
Output is correct |
26 |
Correct |
4 ms |
4180 KB |
Output is correct |
27 |
Correct |
218 ms |
71116 KB |
Output is correct |
28 |
Correct |
5 ms |
9940 KB |
Output is correct |
29 |
Correct |
9 ms |
6484 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
160 ms |
59244 KB |
Output is correct |
32 |
Correct |
147 ms |
71080 KB |
Output is correct |
33 |
Correct |
126 ms |
70860 KB |
Output is correct |
34 |
Correct |
186 ms |
68688 KB |
Output is correct |
35 |
Correct |
143 ms |
71024 KB |
Output is correct |
36 |
Correct |
144 ms |
70796 KB |
Output is correct |
37 |
Correct |
230 ms |
79880 KB |
Output is correct |
38 |
Correct |
108 ms |
65104 KB |
Output is correct |
39 |
Correct |
111 ms |
65132 KB |
Output is correct |