Submission #480844

#TimeUsernameProblemLanguageResultExecution timeMemory
480844ymmBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
391 ms159296 KiB
///
///   breakdown breakdown
///

#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
typedef long long ll;
using namespace std;

const int N = 3010;
char g[N][N];
ll O[N][N];
ll I[N][N];
int n, m;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	Loop(i,0,n)
	{
		Loop(j,0,m)
		{
			cin >> g[i][j];
			if(g[i][j] == 'O') O[i][j]++;
			if(g[i][j] == 'I') I[i][j]++;
		}
	}
	Loop(i,0,n) LoopR(j,0,m-1)
		O[i][j] += O[i][j+1];
	LoopR(i,0,n-1) Loop(j,0,m)
		I[i][j] += I[i+1][j];

	ll ans = 0;
	Loop(i,0,n) Loop(j,0,m)
		if(g[i][j] == 'J')
			ans += O[i][j]*I[i][j];
	cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...