제출 #500421

#제출 시각아이디문제언어결과실행 시간메모리
500421thegrimbeeBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
279 ms160064 KiB
	#include <bits/stdc++.h>
	using namespace std;
	#define int long long
	
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h, w;
	cin >> h >> w;
	vector<string> v(h);
	for (int i = 0; i < h;++i){
		cin >> v[i];
	}
	vector<vector<int>> prefo(h, vector<int> (w));
	vector<vector<int>> prefi(h, vector<int> (w));
	for (int i = 0; i < w; ++i){
		for (int j = 1; j < h; ++j){
			if (v[j][i] == 'I')prefi[j][i] = prefi[j-1][i]+1;
			else prefi[j][i] = prefi[j-1][i];
		}
	}
	for (int i = 0; i < h; ++i){
		for (int j = 1; j < w; ++j){
			if (v[i][j] == 'O')prefo[i][j] = prefo[i][j-1]+1;
			else prefo[i][j] = prefo[i][j-1];
		}
	}
	int ans = 0;
	for (int i = 0; i < h-1; ++i){
		for (int j = 0; j < w-1; ++j){
			if (v[i][j] == 'J'){
				ans += (prefo[i][w-1]-prefo[i][j]) * (prefi[h-1][j] - prefi[i][j]);
			}
		}
	}
	cout << ans;
 }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...