Submission #503881

#TimeUsernameProblemLanguageResultExecution timeMemory
503881bebecanvasBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
454 ms158688 KiB
#include <bits/stdc++.h>

using namespace std;
#define int long long
#define endl '\n'

signed main(){

	int h, w; cin >> h >> w;
	char g[h][w];
	for(int i=0; i<h; i++){
		string s; cin >> s;
		for(int j=0; j<w; j++){
			g[i][j]= s[j];
		}
	}
	
	int c1[h][w];
	for(int i=0; i<h; i++){
		int count= 0;
		for(int j=w-1; j>=0; j--){
			if(g[i][j]=='J'){c1[i][j]= count;}
			else{c1[i][j]= 0;}
			if(g[i][j]=='O'){count++;}
		}
	}
	
	int c2[h][w];
	for(int i=0; i<w; i++){
		int countt= 0;
		for(int j=h-1; j>=0; j--){
			if(g[j][i]=='J'){c2[j][i]= countt;}
			else{c2[j][i]= 0;}
			if(g[j][i]=='I'){countt++;}
		}
	}
	
	int ans= 0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			ans+= (c1[i][j]*c2[i][j]);
		}
	}
	
	cout << ans << endl;
}




#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...