제출 #119276

#제출 시각아이디문제언어결과실행 시간메모리
119276tutisBitaro the Brave (JOI19_ho_t1)C++17
50 / 100
1073 ms14692 KiB
/*input
4 4
JJOO
JJOO
IIJO
IIIJ
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	string s[n];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (s[i][j] != 'J')
				continue;
			ll O = 0;
			ll I = 0;
			for (int a = i + 1; a < n; a++)
				I += (s[a][j] == 'I');
			for (int a = j + 1; a < m; a++)
				O += (s[i][a] == 'O');
			ans += O * I;
		}
	}
	cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...