제출 #899308

#제출 시각아이디문제언어결과실행 시간메모리
899308aykhnBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
246 ms159388 KiB
#include <bits/stdc++.h>
 
// author: aykhn
 
using namespace std;
typedef long long ll;
 
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define mpr make_pair
#define eb emplace_back
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define ins insert
#define int ll
#define inf 0x3F3F3F3F
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount
 
const int MXN = 3e3 + 5;

char mat[MXN][MXN];
int pr[MXN][MXN];
int pc[MXN][MXN];
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> mat[i][j];
            if (mat[i][j] == 'O') pr[i][j] = 1;
            else if (mat[i][j] == 'I') pc[i][j] = 1;
            pr[i][j] += pr[i][j - 1];
            pc[i][j] += pc[i - 1][j];
        }
    }
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (mat[i][j] != 'J') continue;
            res += (pr[i][m] - pr[i][j]) * (pc[n][j] - pc[i][j]);
        }
    }
    cout << res << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...