이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pii pair <ll, ll>
#define st first
#define nd second
#define rep(i, n, m) for (ll i = (n); i <= (m); i ++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i --)
using namespace std;
const long long N = 3000 + 5;
ll n, m, f[N][N], g[N][N];
char a[N][N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    rep(i, 1, n) rep(j, 1, m)
        cin >> a[i][j];
    rep(i, 1, n) {
        rep(j, 1, m) {
            f[i][j] = f[i][j - 1] + (a[i][j] == 'O');
            g[i][j] = g[i - 1][j] + (a[i][j] == 'I');
        }
    }
    ll ans = 0;
    rep(i, 1, n) rep(j, 1, m) if (a[i][j] == 'J') {
        ll cntO = f[i][m] - f[i][j];
        ll cntI = g[n][j] - g[i][j];
        ans += cntO * cntI;
    }
    cout << ans;
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |