Submission #147402

#TimeUsernameProblemLanguageResultExecution timeMemory
147402redaBitaro the Brave (JOI19_ho_t1)C++14
50 / 100
858 ms31028 KiB
#include <bits/stdc++.h>
#define MAX 1010
#define ll long long
using namespace std;
int n, m;
ll ans;
ll PO[MAX][MAX];
ll PI[MAX][MAX];
char v[MAX][MAX];
int main()
{
	cin >> n >> m ;
	for(int g = 1 ; g <= n ; g++)
		for(int h = 1 ; h <= m ; h++)
			cin >> v[g][h];
	for(int g = 1 ; g <= n ; g++)
		for(int h = m ; h > 0 ; h--)
			PO[g][h] = PO[g][h + 1] + (v[g][h] == 'O') ;
	for(int g = n ; g > 0 ; g--)
		for(int h = 1 ; h <= m ; h++)
			PI[g][h] = PI[g + 1][h] + (v[g][h] == 'I') ;
	for(int g = 1 ; g <= n ; g++)
		for(int h = 1 ; h <= m ; h++)
			if(v[g][h] == 'J')
				ans += PO[g][h] * PI[g][h];
	cout << ans ;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...