Submission #1315747

#TimeUsernameProblemLanguageResultExecution timeMemory
1315747mantaggezBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
195 ms150344 KiB
#include <bits/stdc++.h>

using namespace std;

const int nx = 3e3+5;

int h, w;
long long orb[nx][nx], ingot[nx][nx];
char s[nx][nx];

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> h >> w;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin >> s[i][j];

    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            if(s[i][j] == 'O')
                orb[i][j]++;
            orb[i][j] += orb[i][j - 1];
        }
    }

    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            if(s[i][j] == 'I')
                ingot[i][j]++;
            ingot[i][j] += ingot[i - 1][j];
        }
    }
    
    long long res = 0;
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            if(s[i][j] == 'J') {
                res += (orb[i][w] - orb[i][j]) * (ingot[h][j] - ingot[i][j]);
            }
        }
    }

    cout << res ;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...