제출 #1290157

#제출 시각아이디문제언어결과실행 시간메모리
1290157AbdullahIshfaqBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
66 ms10212 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 998244353
void solve()
{
	ll h, w;
	cin >> h >> w;
	string v[h];
	for (ll i = 0; i < h; i++)
		cin >> v[i];
	ll cnt[w] = {0}, ans = 0, k = 0;
	for (ll i = h - 1; i >= 0; i--)
	{
		k = 0;
		for (ll j = w - 1; j >= 0; j--)
		{
			if (v[i][j] == 'J')
				ans += cnt[j] * k;
			else if (v[i][j] == 'O')
				k++;
			else
				cnt[j]++;
		}
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t = 1;
	// cin >> t;
	for (ll i = 1; i <= t; i++)
	{
		solve();
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...