#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3e3+5;
int m, n, cntO[N][N], cntI[N][N];
char c[N][N];
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin >> m >> n;
for (int i = 1; i <= m; ++i)
for (int j = 1; j <= n; ++j) {
cin >> c[i][j];
if (c[i][j] == 'O') cntO[i][j] = 1;
if (c[i][j] == 'I') cntI[i][j] = 1;
}
for (int i = m; i >= 1; --i)
for (int j = n; j >= 1; --j)
cntI[i][j] += cntI[i+1][j],
cntO[i][j] += cntO[i][j+1];
ll res = 0;
for (int i = 1; i <= m; ++i)
for (int j = 1; j <= n; ++j)
if (c[i][j] == 'J')
res += (ll)cntO[i][j] * cntI[i][j];
cout << res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 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 |
1380 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 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 |
1380 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 |
9 ms |
7508 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
4308 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
10 ms |
8020 KB |
Output is correct |
19 |
Correct |
8 ms |
7892 KB |
Output is correct |
20 |
Correct |
7 ms |
7764 KB |
Output is correct |
21 |
Correct |
11 ms |
8020 KB |
Output is correct |
22 |
Correct |
8 ms |
7900 KB |
Output is correct |
23 |
Correct |
7 ms |
7768 KB |
Output is correct |
24 |
Correct |
10 ms |
7928 KB |
Output is correct |
25 |
Correct |
8 ms |
7892 KB |
Output is correct |
26 |
Correct |
7 ms |
7768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 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 |
1380 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 |
9 ms |
7508 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
4308 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
10 ms |
8020 KB |
Output is correct |
19 |
Correct |
8 ms |
7892 KB |
Output is correct |
20 |
Correct |
7 ms |
7764 KB |
Output is correct |
21 |
Correct |
11 ms |
8020 KB |
Output is correct |
22 |
Correct |
8 ms |
7900 KB |
Output is correct |
23 |
Correct |
7 ms |
7768 KB |
Output is correct |
24 |
Correct |
10 ms |
7928 KB |
Output is correct |
25 |
Correct |
8 ms |
7892 KB |
Output is correct |
26 |
Correct |
7 ms |
7768 KB |
Output is correct |
27 |
Correct |
261 ms |
88028 KB |
Output is correct |
28 |
Correct |
11 ms |
25944 KB |
Output is correct |
29 |
Correct |
17 ms |
7832 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
195 ms |
72528 KB |
Output is correct |
32 |
Correct |
217 ms |
88436 KB |
Output is correct |
33 |
Correct |
170 ms |
88168 KB |
Output is correct |
34 |
Correct |
232 ms |
84056 KB |
Output is correct |
35 |
Correct |
211 ms |
88412 KB |
Output is correct |
36 |
Correct |
170 ms |
88228 KB |
Output is correct |
37 |
Correct |
276 ms |
88412 KB |
Output is correct |
38 |
Correct |
144 ms |
72528 KB |
Output is correct |
39 |
Correct |
132 ms |
72192 KB |
Output is correct |