제출 #259066

#제출 시각아이디문제언어결과실행 시간메모리
259066FidiskBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
229 ms184056 KiB
#include <bits/stdc++.h>
using namespace std;

#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

const ld pi=acos(-1);

string s[5009];
ll n,m,i,j,f1[5009][5009],f2[5009][5009],res;

int main(){
    IO;
    cin>>n>>m;
    for (i=1;i<=n;i++) {
        cin>>s[i];
    } 
    for (i=1;i<=n;i++) {
        for (j=m;j>=1;j--) {
            if (s[i][j-1]=='O') {
                f1[i][j]=f1[i][j+1]+1;
            }
            else {
                f1[i][j]=f1[i][j+1];
            }
        }
    }
    for (i=n;i>=1;i--) {
        for (j=1;j<=m;j++) {
            if (s[i][j-1]=='I') {
                f2[i][j]=f2[i+1][j]+1;
            }
            else {
                f2[i][j]=f2[i+1][j];
            }
        }
    }
    for (i=1;i<=n;i++) {
        for (j=1;j<=m;j++) {
            if (s[i][j-1]=='J') {
                res+=f1[i][j]*f2[i][j];
            }
        }
    }
    cout<<res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...