이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
inline void solve()
{
    int n, m;
    cin >> n >> m;
    vector<string> v(n);
    for (auto &i : v)
        cin >> i;
    
    vector<vector<int>> ii(n + 1, vector<int>(m + 1, 0)), oo(ii);
    for (int i = n - 1; i >= 0; --i)
        for (int j = 0; j < m; ++j)
            ii[i][j] = ii[i + 1][j] + (v[i][j] == 'I');
    for (int j = m - 1; j >= 0; --j)
        for (int i = 0; i < n; ++i)
            oo[i][j] = oo[i][j + 1] + (v[i][j] == 'O');
    
    int ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (v[i][j] == 'J')
                ans += ii[i][j] * oo[i][j];
    cout << ans << '\n';
}
signed main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    solve();
    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... |