#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, ans, si[3010][3010], so[3010][3010];
char a[3010][3010];
int main() {
cin.tie(0); cout.tie(0);
ios::sync_with_stdio(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
if (a[i][j] == 'O') {
so[i][j]++;
}
else if (a[i][j] == 'I') {
si[i][j]++;
}
so[i][j] += so[i][j-1];
si[i][j] += si[i-1][j];
}
}
ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == 'J') {
ans += (so[i][m]-so[i][j])*(si[n][j]-si[i][j]);
}
}
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 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 |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 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 |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 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 |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
10 ms |
9008 KB |
Output is correct |
15 |
Correct |
3 ms |
5064 KB |
Output is correct |
16 |
Correct |
7 ms |
5332 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
13 ms |
9940 KB |
Output is correct |
19 |
Correct |
10 ms |
9752 KB |
Output is correct |
20 |
Correct |
9 ms |
9708 KB |
Output is correct |
21 |
Correct |
13 ms |
9964 KB |
Output is correct |
22 |
Correct |
10 ms |
9812 KB |
Output is correct |
23 |
Correct |
9 ms |
9812 KB |
Output is correct |
24 |
Correct |
13 ms |
9944 KB |
Output is correct |
25 |
Correct |
10 ms |
9820 KB |
Output is correct |
26 |
Correct |
9 ms |
9688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 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 |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
10 ms |
9008 KB |
Output is correct |
15 |
Correct |
3 ms |
5064 KB |
Output is correct |
16 |
Correct |
7 ms |
5332 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
13 ms |
9940 KB |
Output is correct |
19 |
Correct |
10 ms |
9752 KB |
Output is correct |
20 |
Correct |
9 ms |
9708 KB |
Output is correct |
21 |
Correct |
13 ms |
9964 KB |
Output is correct |
22 |
Correct |
10 ms |
9812 KB |
Output is correct |
23 |
Correct |
9 ms |
9812 KB |
Output is correct |
24 |
Correct |
13 ms |
9944 KB |
Output is correct |
25 |
Correct |
10 ms |
9820 KB |
Output is correct |
26 |
Correct |
9 ms |
9688 KB |
Output is correct |
27 |
Correct |
298 ms |
158848 KB |
Output is correct |
28 |
Correct |
15 ms |
26228 KB |
Output is correct |
29 |
Correct |
17 ms |
13852 KB |
Output is correct |
30 |
Correct |
1 ms |
724 KB |
Output is correct |
31 |
Correct |
227 ms |
131660 KB |
Output is correct |
32 |
Correct |
231 ms |
159148 KB |
Output is correct |
33 |
Correct |
199 ms |
158796 KB |
Output is correct |
34 |
Correct |
266 ms |
152620 KB |
Output is correct |
35 |
Correct |
254 ms |
159268 KB |
Output is correct |
36 |
Correct |
201 ms |
158700 KB |
Output is correct |
37 |
Correct |
312 ms |
159248 KB |
Output is correct |
38 |
Correct |
172 ms |
130864 KB |
Output is correct |
39 |
Correct |
169 ms |
131084 KB |
Output is correct |