Submission #1258706

#TimeUsernameProblemLanguageResultExecution timeMemory
1258706truongnhattungBitaro the Brave (JOI19_ho_t1)C++20
20 / 100
8 ms7752 KiB
#include <bits/stdc++.h>

using namespace std;
int h, w;
char a[3005][3005];
int o[3005][3005];
int b[3005][3005];
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> h >> w;
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            o[i][j] += o[i][j - 1] + (a[i][j] == 'O');
        }
    }
    for(int i = 1; i <= w; i++) {
        for(int j = 1; j <= h; j++) {
            b[i][j] += b[i][j - 1] + (a[j][i] == 'I');
        }
    }
    /*for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cout << b[i][j] << ' ';
        }
        cout << '\n';
    }*/
    int res = 0;
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if(a[i][j] == 'J') {
                res += (o[i][w] - o[i][j]) * (b[j][h] - b[j][i]);
            }
        }
    }
    cout << res;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...