Submission #208067

#TimeUsernameProblemLanguageResultExecution timeMemory
208067w4123Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
774 ms82424 KiB


#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...