제출 #377890

#제출 시각아이디문제언어결과실행 시간메모리
377890smjleoBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
409 ms159212 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long
#define nl '\n'
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
mt19937 rng((unsigned)chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1000000007, mod2 = 998244353;

// change this
const int N = 3005;

int n, m, ao[N][N], ai[N][N], ans;
char arr[N][N];

signed main() {
    io;
    cin >> n >> m;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            cin >> arr[i][j];
            if (arr[i][j] == 'O') ao[i][j]++;
            else if (arr[i][j] == 'I') ai[i][j]++;
            ao[i][j] += ao[i][j-1];
            ai[i][j] += ai[i-1][j];
        }
    }

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            if (arr[i][j] != 'J') continue;
            int x = ao[i][m] - ao[i][j], y = ai[n][j] - ai[i][j];
            ans += x * y;
        }
    }
    
    cout << ans << nl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...