Submission #478916

#TimeUsernameProblemLanguageResultExecution timeMemory
478916IvnFBitaro the Brave (JOI19_ho_t1)C++14
20 / 100
7 ms4924 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ull unsigned long long
#define fi first
#define se second
#define ld long double
ll n, m;
char arr[3005][3005], pi[3005][3005], po[3005][3005];

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