제출 #894140

#제출 시각아이디문제언어결과실행 시간메모리
894140ByeWorldBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
419 ms161876 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define bupol __builtin_popcount
#define int long long
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
const int MAXN = 3e3+10;
const int LOG = 20;
const int MOD = 1e9+7;
const int SQRT = 520;
const int INF = 1e18;
typedef pair<int,int> pii;
typedef pair<int,pii> ipii;

int n, m;
string s[MAXN];
int row[MAXN][MAXN], col[MAXN][MAXN];

signed main(){
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i=0; i<n; i++) cin >> s[i];
    for(int j=m-1; j>=0; j--){
        for(int i=0; i<n; i++){
            row[i][j] = row[i][j+1];
            if(s[i][j]=='O') row[i][j]++;
        }
    }
    for(int i=n-1; i>=0; i--){
        for(int j=0; j<m; j++){
            col[i][j] = col[i+1][j];
            if(s[i][j]=='I') col[i][j]++;
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(s[i][j] == 'J'){
                ans += row[i][j] * col[i][j];
            }
        }
    }
    cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...