This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |