Submission #597199

#TimeUsernameProblemLanguageResultExecution timeMemory
597199BelphegorBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
215 ms53152 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
char arr[3005][3005];
short dp[3005][3005];
short DP[3005][3005];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n,m; cin>>n>>m;
	for(int i=1; i<=n; i++) cin>>(arr[i]+1);
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if(arr[i][j]=='O') dp[i][j] = 1;
			if(arr[i][j]=='I') DP[i][j] = 1;
		}
		for(int j=m; j>=1; j--) dp[i][j]+=dp[i][j+1];
	}
	for(int i=1; i<=m; i++){
		for(int j=n; j>=1; j--) DP[j][i]+=DP[j+1][i];
	}
	ll ans = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if(arr[i][j]!='J') continue;
			ll w = dp[i][j];
			w*=DP[i][j];
			ans+=w;
		}
	}
	cout<<ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...