#include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
using ll = long long;
const int MAXDIM = 3001;
char grid[MAXDIM][MAXDIM];
ll suffix_row[MAXDIM][MAXDIM];
ll suffix_col[MAXDIM][MAXDIM];
int main(void)
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int nb_lig, nb_col;
cin >> nb_lig >> nb_col;
for (int lig(0); lig < nb_lig; ++lig)
for (int col(0); col < nb_col; ++col)
cin >> grid[lig][col];
for (int lig(nb_lig-1); lig >= 0; --lig)
for (int col(nb_col-1); col >= 0; --col)
{
suffix_row[lig][col] = suffix_row[lig][col+1] + (grid[lig][col] == 'O');
suffix_col[lig][col] = suffix_col[lig+1][col] + (grid[lig][col] == 'I');
}
ll ans(0);
for (int lig(0); lig < nb_lig; ++lig)
for (int col(0); col < nb_col; ++col)
if (grid[lig][col] == 'J')
ans += suffix_row[lig][col] * suffix_col[lig][col];
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
1712 KB |
Output is correct |
6 |
Correct |
6 ms |
1664 KB |
Output is correct |
7 |
Correct |
5 ms |
1536 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1664 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
1712 KB |
Output is correct |
6 |
Correct |
6 ms |
1664 KB |
Output is correct |
7 |
Correct |
5 ms |
1536 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1664 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
14 |
Correct |
13 ms |
8832 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
9 ms |
5248 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
14 ms |
9728 KB |
Output is correct |
19 |
Correct |
14 ms |
9600 KB |
Output is correct |
20 |
Correct |
13 ms |
9600 KB |
Output is correct |
21 |
Correct |
15 ms |
9984 KB |
Output is correct |
22 |
Correct |
13 ms |
9856 KB |
Output is correct |
23 |
Correct |
13 ms |
9856 KB |
Output is correct |
24 |
Correct |
14 ms |
9984 KB |
Output is correct |
25 |
Correct |
13 ms |
9856 KB |
Output is correct |
26 |
Correct |
14 ms |
9788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
1712 KB |
Output is correct |
6 |
Correct |
6 ms |
1664 KB |
Output is correct |
7 |
Correct |
5 ms |
1536 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1664 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
14 |
Correct |
13 ms |
8832 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
9 ms |
5248 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
14 ms |
9728 KB |
Output is correct |
19 |
Correct |
14 ms |
9600 KB |
Output is correct |
20 |
Correct |
13 ms |
9600 KB |
Output is correct |
21 |
Correct |
15 ms |
9984 KB |
Output is correct |
22 |
Correct |
13 ms |
9856 KB |
Output is correct |
23 |
Correct |
13 ms |
9856 KB |
Output is correct |
24 |
Correct |
14 ms |
9984 KB |
Output is correct |
25 |
Correct |
13 ms |
9856 KB |
Output is correct |
26 |
Correct |
14 ms |
9788 KB |
Output is correct |
27 |
Correct |
240 ms |
158436 KB |
Output is correct |
28 |
Correct |
19 ms |
26368 KB |
Output is correct |
29 |
Correct |
22 ms |
13952 KB |
Output is correct |
30 |
Correct |
5 ms |
896 KB |
Output is correct |
31 |
Correct |
194 ms |
131320 KB |
Output is correct |
32 |
Correct |
221 ms |
158840 KB |
Output is correct |
33 |
Correct |
214 ms |
158328 KB |
Output is correct |
34 |
Correct |
216 ms |
152184 KB |
Output is correct |
35 |
Correct |
223 ms |
158840 KB |
Output is correct |
36 |
Correct |
218 ms |
158328 KB |
Output is correct |
37 |
Correct |
264 ms |
158972 KB |
Output is correct |
38 |
Correct |
167 ms |
130808 KB |
Output is correct |
39 |
Correct |
162 ms |
130680 KB |
Output is correct |