제출 #208464

#제출 시각아이디문제언어결과실행 시간메모리
208464AlainSuBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
913 ms154220 KiB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=3003, MAXM=3003;
char s[3010][3010]={};
long long O[MAXN][MAXM]={},I[MAXN][MAXM]={},n,m;
long long ans=0;
void input()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	    for (int j=1;j<=m;j++)
	         cin>>s[i][j];
}
void getO()
{
	for (int i=1;i<=n;i++)
	     for (int j=1;j<=m;j++)
	         {
	         	if (j!=1) {O[i][j]=O[i][j-1];};
	         	if (s[i][j]=='O') {O[i][j]++;}; 
			 }
}
void getI()
{
	for (int i=1;i<=n;i++)
	   for (int j=1;j<=m;j++)
	        {
	        	if (i!=1) {I[i][j]=I[i-1][j];};
	        	if (s[i][j]=='I') {I[i][j]++;};
			}
}
void process()
{
	for (int i=1;i<=n;i++)
	    for (int j=1;j<=m;j++)
	         if (s[i][j]=='J')
	         {
	         	ans+=(I[n][j]-I[i][j])*(O[i][m]-O[i][j]);
			 }
}
void output()
{
	cout<<ans;
}
int main()
{
    input();
    getO();
    getI();
    process();
    output();
    return 0;
} 
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...