#include <bits/stdc++.h>
using namespace std;
long long orbes[3010][3010];
long long ingots[3010][3010];
char grid[3010][3010];
int main()
{
long long h, w;
cin >> h >> w;
for (long long i = 0; i < h; i++)
{
for (long long j = 0; j < w; j++)
{
cin >> grid[i][j];
}
}
for (long long i = 0; i < h; i++)
{
for (long long j = w; j >= 0; j--)
{
orbes[i][j] = orbes[i][j+1] + (grid[i][j] == 'O');
}
}
for (long long j = 0; j < w; j++)
{
for (long long i = h; i >= 0; i--)
{
ingots[i][j] = ingots[i+1][j] + (grid[i][j] == 'I');
}
}
long long ans = 0;
for (long long i = 0; i < h; i++)
{
for (long long j = 0; j < w; j++)
{
if (grid[i][j] == 'J')
{
ans += ingots[i][j] * orbes[i][j];
}
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 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 |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 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 |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
14 |
Correct |
16 ms |
8816 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
10 ms |
5204 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
20 ms |
9732 KB |
Output is correct |
19 |
Correct |
19 ms |
9484 KB |
Output is correct |
20 |
Correct |
20 ms |
9492 KB |
Output is correct |
21 |
Correct |
20 ms |
9644 KB |
Output is correct |
22 |
Correct |
19 ms |
9552 KB |
Output is correct |
23 |
Correct |
21 ms |
9472 KB |
Output is correct |
24 |
Correct |
20 ms |
9648 KB |
Output is correct |
25 |
Correct |
19 ms |
9588 KB |
Output is correct |
26 |
Correct |
18 ms |
9484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 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 |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
14 |
Correct |
16 ms |
8816 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
10 ms |
5204 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
20 ms |
9732 KB |
Output is correct |
19 |
Correct |
19 ms |
9484 KB |
Output is correct |
20 |
Correct |
20 ms |
9492 KB |
Output is correct |
21 |
Correct |
20 ms |
9644 KB |
Output is correct |
22 |
Correct |
19 ms |
9552 KB |
Output is correct |
23 |
Correct |
21 ms |
9472 KB |
Output is correct |
24 |
Correct |
20 ms |
9648 KB |
Output is correct |
25 |
Correct |
19 ms |
9588 KB |
Output is correct |
26 |
Correct |
18 ms |
9484 KB |
Output is correct |
27 |
Correct |
682 ms |
150540 KB |
Output is correct |
28 |
Correct |
17 ms |
26248 KB |
Output is correct |
29 |
Correct |
45 ms |
13260 KB |
Output is correct |
30 |
Correct |
2 ms |
724 KB |
Output is correct |
31 |
Correct |
507 ms |
125400 KB |
Output is correct |
32 |
Correct |
663 ms |
150448 KB |
Output is correct |
33 |
Correct |
669 ms |
149940 KB |
Output is correct |
34 |
Correct |
583 ms |
145480 KB |
Output is correct |
35 |
Correct |
674 ms |
150536 KB |
Output is correct |
36 |
Correct |
676 ms |
149964 KB |
Output is correct |
37 |
Correct |
701 ms |
150572 KB |
Output is correct |
38 |
Correct |
482 ms |
124728 KB |
Output is correct |
39 |
Correct |
482 ms |
124996 KB |
Output is correct |