Submission #1369908

#TimeUsernameProblemLanguageResultExecution timeMemory
1369908hovuviettruongBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
129 ms150304 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define el '\n'
#define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define N 1000006
using namespace std;

char A[3003][3003];
int col[3003][3003], row[3003][3003];

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            cin >> A[i][j];
            row[i][j] = row[i][j - 1] + (A[i][j] == 'O');
            col[i][j] = col[i - 1][j] + (A[i][j] == 'I');
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            if (A[i][j] == 'J' && row[i][m] - row[i][j] > 0 && col[n][j] - col[i][j] > 0) {
                ans += (row[i][m] - row[i][j]) * (col[n][j] - col[i][j]);
            }
        }
    }

    cout << ans;
    





}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...