제출 #1018126

#제출 시각아이디문제언어결과실행 시간메모리
1018126ag_1204Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
167 ms158736 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define pb push_back
 
void solve() {
    int n,m;
    cin>>n>>m;
    char grid[n][m];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            cin>>grid[i][j];
        }
    }
    int ans = 0;
    int a[n][m],b[n][m];
    for(int i = n - 1;i >= 0;i--){
        for(int j = m - 1;j >= 0;j--){
            a[i][j] = (j == m - 1?0:a[i][j + 1]) + (grid[i][j] == 'O');
            b[i][j] = (i == n - 1?0:b[i + 1][j]) + (grid[i][j] == 'I');
            if(grid[i][j] == 'J')ans+=a[i][j]*b[i][j];
        }
    }
    cout<<ans;
    return;
}
 
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int tt=1; //cin>>tt;
	while(tt--) {
	    solve();
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...