#include <bits/stdc++.h>
using namespace std;
int orbes[3010][3010];
int ingots[3010][3010];
char grid[3010][3010];
int main()
{
int h, w;
cin >> h >> w;
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
cin >> grid[i][j];
}
}
for (int i = 0; i < h; i++)
{
for (int j = w; j >= 0; j--)
{
orbes[i][j] = orbes[i][j+1] + (grid[i][j] == 'O');
}
}
for (int j = 0; j < w; j++)
{
for (int i = h; i >= 0; i--)
{
ingots[i][j] = ingots[i+1][j] + (grid[i][j] == 'I');
}
}
int ans = 0;
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
if (grid[i][j] == 'J')
{
ans += ingots[i][j] * orbes[i][j];
}
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 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 |
1364 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1364 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 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 |
1364 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1364 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
7200 KB |
Output is correct |
15 |
Correct |
4 ms |
4948 KB |
Output is correct |
16 |
Correct |
10 ms |
4156 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
7636 KB |
Output is correct |
19 |
Correct |
19 ms |
7612 KB |
Output is correct |
20 |
Incorrect |
20 ms |
7636 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 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 |
1364 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1364 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
7200 KB |
Output is correct |
15 |
Correct |
4 ms |
4948 KB |
Output is correct |
16 |
Correct |
10 ms |
4156 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
7636 KB |
Output is correct |
19 |
Correct |
19 ms |
7612 KB |
Output is correct |
20 |
Incorrect |
20 ms |
7636 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |