#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
int n, m;
char table[maxn][maxn];
int preffix1[maxn][maxn];
int preffix2[maxn][maxn];
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n >> m;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
cin >> table[i][j];
}
}
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
preffix1[i][j] = preffix1[i][j - 1] + (table[i][j] == 'O');
}
}
for (int j = 1; j <= m; ++j)
{
for (int i = 1; i <= n; ++i)
{
preffix2[i][j] = preffix2[i - 1][j] + (table[i][j] == 'I');
}
}
long long ans = 0;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
if (table[i][j] == 'J')
{
ans += (preffix1[i][m] - preffix1[i][j]) * (preffix2[n][j] - preffix2[i][j]);
}
}
}
cout << ans << endl;
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 |
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 |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 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 |
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 |
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 |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
8 ms |
7252 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
4180 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
7 ms |
7692 KB |
Output is correct |
19 |
Correct |
6 ms |
7636 KB |
Output is correct |
20 |
Correct |
6 ms |
7508 KB |
Output is correct |
21 |
Correct |
7 ms |
7764 KB |
Output is correct |
22 |
Correct |
8 ms |
7640 KB |
Output is correct |
23 |
Correct |
6 ms |
7508 KB |
Output is correct |
24 |
Correct |
7 ms |
7764 KB |
Output is correct |
25 |
Correct |
6 ms |
7636 KB |
Output is correct |
26 |
Correct |
7 ms |
7596 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 |
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 |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
8 ms |
7252 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
4180 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
7 ms |
7692 KB |
Output is correct |
19 |
Correct |
6 ms |
7636 KB |
Output is correct |
20 |
Correct |
6 ms |
7508 KB |
Output is correct |
21 |
Correct |
7 ms |
7764 KB |
Output is correct |
22 |
Correct |
8 ms |
7640 KB |
Output is correct |
23 |
Correct |
6 ms |
7508 KB |
Output is correct |
24 |
Correct |
7 ms |
7764 KB |
Output is correct |
25 |
Correct |
6 ms |
7636 KB |
Output is correct |
26 |
Correct |
7 ms |
7596 KB |
Output is correct |
27 |
Correct |
266 ms |
79704 KB |
Output is correct |
28 |
Correct |
12 ms |
26060 KB |
Output is correct |
29 |
Correct |
11 ms |
7764 KB |
Output is correct |
30 |
Correct |
1 ms |
608 KB |
Output is correct |
31 |
Correct |
199 ms |
72576 KB |
Output is correct |
32 |
Correct |
262 ms |
88452 KB |
Output is correct |
33 |
Correct |
253 ms |
88120 KB |
Output is correct |
34 |
Correct |
199 ms |
84044 KB |
Output is correct |
35 |
Correct |
240 ms |
88396 KB |
Output is correct |
36 |
Correct |
261 ms |
88108 KB |
Output is correct |
37 |
Correct |
262 ms |
88524 KB |
Output is correct |
38 |
Correct |
176 ms |
72444 KB |
Output is correct |
39 |
Correct |
168 ms |
72228 KB |
Output is correct |