이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()
template<class S, class T>
bool chmin(S &a, const T &b) {
    return a > b && (a = b) == b;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
    return a < b && (a = b) == b;
}
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
const int mod = 1e9 + 7;
signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m; cin >> n >> m;
    string s[n];
    for (int i = 0; i < n; ++i) cin >> s[i];
    int prefi[n][m], prefj[n][m];
    for (int i = 0; i < n; ++i) {
        prefi[i][0] = s[i][0] == 'O';
        for (int j = 1; j < m; ++j) {
            prefi[i][j] = prefi[i][j - 1] + (s[i][j] == 'O');
        }
    }
    for (int j = 0; j < m; ++j) {
        prefj[0][j] = s[0][j] == 'I';
        for (int i = 1; i < n; ++i) {
            prefj[i][j] = prefj[i - 1][j] + (s[i][j] == 'I');
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == 'J')
                res += (prefi[i][m - 1] - prefi[i][j]) * (prefj[n - 1][j] - prefj[i][j]);
        }
    }
    cout << res;
} 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |