/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 3010;
int n, m;
ll row[maxn][maxn], col[maxn][maxn];
char c[maxn][maxn];
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
{
cin >> c[i][j];
if (c[i][j] == 'O')
row[i][j] ++;
else if (c[i][j] == 'I')
col[i][j] ++;
}
for (int i = 1; i <= n; i ++)
for (int j = m; j > 0; j --)
row[i][j] = row[i][j + 1] + row[i][j];
for (int j = 1; j <= m; j ++)
for (int i = n; i > 0; i --)
col[i][j] = col[i + 1][j] + col[i][j];
ll ans = 0;
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= m; j ++)
{
if (c[i][j] == 'J')
{
ans = ans + row[i][j] * col[i][j];
///cout << i << " " << j << " " << row[i][j] * col[i][j] << endl;
}
}
}
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
/**
3 4
JOIJ
JIOO
IIII
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1460 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 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 |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1460 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 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 |
17 ms |
8916 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
12 ms |
5304 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
22 ms |
9956 KB |
Output is correct |
19 |
Correct |
20 ms |
9684 KB |
Output is correct |
20 |
Correct |
19 ms |
9708 KB |
Output is correct |
21 |
Correct |
21 ms |
9920 KB |
Output is correct |
22 |
Correct |
20 ms |
9804 KB |
Output is correct |
23 |
Correct |
19 ms |
9684 KB |
Output is correct |
24 |
Correct |
23 ms |
9912 KB |
Output is correct |
25 |
Correct |
21 ms |
9716 KB |
Output is correct |
26 |
Correct |
19 ms |
9680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1460 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 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 |
17 ms |
8916 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
12 ms |
5304 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
22 ms |
9956 KB |
Output is correct |
19 |
Correct |
20 ms |
9684 KB |
Output is correct |
20 |
Correct |
19 ms |
9708 KB |
Output is correct |
21 |
Correct |
21 ms |
9920 KB |
Output is correct |
22 |
Correct |
20 ms |
9804 KB |
Output is correct |
23 |
Correct |
19 ms |
9684 KB |
Output is correct |
24 |
Correct |
23 ms |
9912 KB |
Output is correct |
25 |
Correct |
21 ms |
9716 KB |
Output is correct |
26 |
Correct |
19 ms |
9680 KB |
Output is correct |
27 |
Correct |
698 ms |
158844 KB |
Output is correct |
28 |
Correct |
13 ms |
26324 KB |
Output is correct |
29 |
Correct |
50 ms |
13844 KB |
Output is correct |
30 |
Correct |
3 ms |
792 KB |
Output is correct |
31 |
Correct |
520 ms |
131592 KB |
Output is correct |
32 |
Correct |
679 ms |
159140 KB |
Output is correct |
33 |
Correct |
663 ms |
158776 KB |
Output is correct |
34 |
Correct |
626 ms |
152560 KB |
Output is correct |
35 |
Correct |
680 ms |
159156 KB |
Output is correct |
36 |
Correct |
646 ms |
158748 KB |
Output is correct |
37 |
Correct |
747 ms |
159304 KB |
Output is correct |
38 |
Correct |
466 ms |
130736 KB |
Output is correct |
39 |
Correct |
474 ms |
130956 KB |
Output is correct |