제출 #1162640

#제출 시각아이디문제언어결과실행 시간메모리
1162640VidicyBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
184 ms150092 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pll pair<long long, long long>
#define st string
#define fr first
#define sec second
#define pb push_back
#define beg begin
#define INF 1e18
#define MOD 1e9+7

int n, m;
char a[3000][3000];
int ai[3000][3000];
int ao[3000][3000];

void solve() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            ao[i][j] = (a[i][j] == 'O') + (j < m - 1 ? ao[i][j + 1] : 0);
            ai[i][j] = (a[i][j] == 'I') + (i < n - 1 ? ai[i + 1][j] : 0);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (a[i][j] == 'J') {
                ans += ao[i][j] * ai[i][j];
            }
        }
    }
    cout << ans << endl;
}


signed main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);cout << setprecision(20);
    //    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    int T = 1;
    //cin >> T;
    while(T--) {
        solve();
    }

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