제출 #962976

#제출 시각아이디문제언어결과실행 시간메모리
962976marinalucaBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
256 ms158928 KiB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize ("O4")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")

using namespace std;
#define int long long
#define ll long long
#define XX first
#define YY second
#define pb push_back
#define sz (x) int(x.size())
#define pf pop_front
#define pob pop_back
#define pff push_front

const int NMAX = 3e3;
int n, m;
char v[NMAX + 1][NMAX + 1];
int w[NMAX + 1][NMAX + 1];
int matrix[NMAX + 1][NMAX + 1];
signed main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    for (int i = 1; i <= n; ++ i){
        for (int j = 1; j <= m; ++ j){
            cin >> v[i][j];
            matrix[i][j] = matrix[i][j - 1];
             w[i][j] = w[i - 1][j];
            if (v[i][j] == 'O')
                matrix[i][j] ++;
            if (v[i][j] == 'I')
                w[i][j] ++;
        }
    }
    int sum = 0;
    for (int i = 1; i <= n; ++ i){
        for (int j = 1; j <= m; ++ j){
            if (v[i][j] == 'J'){
                sum += (w[n][j] - w[i - 1][j]) * (matrix[i][m] - matrix[i][j - 1]);
            }
        }
    }
    cout << sum << "\n";
    return 0 ^ 0;   
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...