Submission #478100

#TimeUsernameProblemLanguageResultExecution timeMemory
478100FireGhost1301Bitaro the Brave (JOI19_ho_t1)C++11
100 / 100
220 ms81396 KiB
/**
    __author__ : FireGhost
    problems_ID: JOI19_ho_t1
 */

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;

const int N = 3000 + 3;
const int MOD = 1e9 + 7;

int n, m, row_prf[N][N], col_prf[N][N];
char c[N][N];

void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> c[i][j];
            row_prf[i][j] = row_prf[i][j - 1] + (c[i][j] == 'O');
            col_prf[i][j] = col_prf[i - 1][j] + (c[i][j] == 'I');
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (c[i][j] == 'J')
                ans += (row_prf[i][m] - row_prf[i][j]) * (col_prf[n][j] - col_prf[i][j]);
        }
    }
    cout << ans;
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int t = 1;
    while (t--)
        solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...