Submission #544900

#TimeUsernameProblemLanguageResultExecution timeMemory
544900inluminasBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
158 ms89356 KiB
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false)
#define inf LLONG_MAX

int main(){
	fastio;

	int h,w;
	cin>>h>>w;
	string s[h+1];
	int o[h+1][w+1],I[h+1][w+1];
	for(int i=1;i<=h;i++){
		cin>>s[i];
	}
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			o[i][j]=I[i][j]=0;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			o[i][j]=o[i][j-1];
			I[i][j]=I[i-1][j];
			if(s[i][j-1]=='I') I[i][j]++;
			if(s[i][j-1]=='O') o[i][j]++;
		}
	}

	ll ans=0;

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(s[i][j-1]=='J'){
				ans+=(o[i][w]-o[i][j])*(I[h][j]-I[i][j]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...