제출 #942036

#제출 시각아이디문제언어결과실행 시간메모리
942036carriewangBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
108 ms160188 KiB
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
const int maxn=3005;
ll h,w,a[maxn][maxn],b[maxn][maxn];
string s[maxn];
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    ll ans=0;
    for(int i=h-1;i>=0;i--){
        for(int j=w-1;j>=0;j--){
            a[i][j]=a[i+1][j];
            b[i][j]=b[i][j+1];
            if(s[i][j]=='I') a[i][j]++;
            else if(s[i][j]=='O') b[i][j]++;
            else ans+=a[i][j]*b[i][j];
        }
    }
    cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...