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 <iostream>
#include <vector>
#include <string>
using namespace std;
int Orb_Count[3005][3005];
int Ingot_Count[3005][3005];
int main()
{
int H, W;
cin >> H >> W;
vector<string> vs(H);
for (int i = 0; i != H; i++)
{
cin >> vs[i];
if (vs[i][0] == 'O')Orb_Count[i][0] = 1;
for (int j = 1; j != W; j++)
{
if (vs[i][j] == 'O')
{
Orb_Count[i][j] = Orb_Count[i][j - 1] + 1;
}
else
{
Orb_Count[i][j] = Orb_Count[i][j - 1];
}
}
}
for (int i = 0; i != W; i++)
{
if (vs[0][i] == 'I')Ingot_Count[0][i] = 1;
for (int j = 1; j != H; j++)
{
if (vs[j][i] == 'I')Ingot_Count[j][i] = Ingot_Count[j - 1][i] + 1;
else Ingot_Count[j][i] = Ingot_Count[j - 1][i];
}
}
long long Ans = 0;
for (int i = 0; i != H; i++)
{
for (int j = 0; j != W; j++)
{
if (vs[i][j] == 'J')
{
Ans += (Orb_Count[i][W - 1] - Orb_Count[i][j]) * (Ingot_Count[H - 1][j] - Ingot_Count[i][j]);
//cout << "I: " << i << " J: " << j << " ORB_COUNT: " << Ingot_Count[i][j] << " " << Ingot_Count[i][W - 1];
}
}
}
cout << Ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |