Submission #1258709

#TimeUsernameProblemLanguageResultExecution timeMemory
1258709truongnhattungBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
218 ms150412 KiB
#include <bits/stdc++.h>
#define int long long
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...