Submission #307318

#TimeUsernameProblemLanguageResultExecution timeMemory
307318TemmieBitaro the Brave (JOI19_ho_t1)C++17
0 / 100
162 ms274432 KiB
#include <bits/stdc++.h>

typedef long long ll;

int main() {
	std::ios::sync_with_stdio(0);
	
	int h, w; std::cin >> h >> w;
	std::vector <std::string> g(h);
	std::vector <std::vector <ll>> a(4269, std::vector <ll> (4269, 0)), b(a);
	for (auto& x : g) std::cin >> x;
	for (int i = 0; i < w; i++)
		for (int j = h - 1; j >= 0; j--)
			b[i][j] = (j != h - 1 ? b[i][j + 1] : 0) + (g[j][i] == 'I');
	for (int i = 0; i < h; i++)
		for (int j = w - 1; j >= 0; j--)
			a[i][j] = (j != w - 1 ? a[i][j + 1] : 0) + (g[i][j] == 'O');
	ll ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			ans += (g[i][j] == 'J') * a[i][j] * b[j][i];
	std::cout << ans << "\n";
	
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...