Submission #1192099

#TimeUsernameProblemLanguageResultExecution timeMemory
1192099badge881Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
339 ms82456 KiB
#include <bits/stdc++.h>
using namespace std;

string tab[3007];
int prefk[3007][3007];
int prefw[3007][3007];

int main() 
{
	int h, w;
	cin >> h >> w;
	for(int i = 1; i <= h; i++)
		cin >> tab[i];
	
	for(int i = h; i >= 1; i--)
		for(int j = w - 1; j >= 0; j--)
		{
			prefw[i][j + 1] = prefw[i][j + 2];
			if(tab[i][j] == 'O')
				prefw[i][j + 1]++;
		}
	
	for(int j = w - 1; j >= 0; j--)
		for(int i = h; i >= 1; i--)
		{
			prefk[i][j + 1] = prefk[i + 1][j + 1];
			if(tab[i][j] == 'I')
				prefk[i][j + 1]++;
			
		}
	
	long long ans = 0;
	for(int i = 1; i <= h; i++)
		for(int j = 0; j < w; j++)
			if(tab[i][j] == 'J')
				ans += prefk[i][j + 1] * prefw[i][j + 1];

	cout << ans << endl;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...