제출 #1317750

#제출 시각아이디문제언어결과실행 시간메모리
1317750vtnooBitaro the Brave (JOI19_ho_t1)C++20
20 / 100
9 ms6712 KiB
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=3005;
int cnti[N][N],cnto[N][N];
int main(){
	int h,w;cin>>h>>w;
	vector<string>g(h);
	for(int i=0;i<h;i++)cin>>g[i];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(g[i][j]=='I'){
				cnti[i][j]++;
			}else if(g[i][j]=='O'){
				cnto[i][j]++;
			}
		}
	}
	int ans=0;
	for(int j=w-1;j>=0;j--){
		for(int i=h-2;i>=0;i--){
			cnti[i][j]+=cnti[i+1][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=w-2;j>=0;j--){
			cnto[i][j]+=cnto[i][j+1];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(g[i][j]!='J')continue;
			if(cnti[i][j]>0&&cnto[i][j]>0){
				ans+=cnti[i][j]*cnto[i][j];
			}
		}
	}
	cout<<ans<<endl;	
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...