제출 #212005

#제출 시각아이디문제언어결과실행 시간메모리
212005AQTBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
397 ms88568 KiB
#include <bits/stdc++.h>

using namespace std;

int N, M;
int ingot[3005][3005];
int orb[3005][3005];
char mp[3005][3005];

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M;
	for(int i = 1; i<=N; i++){
		for(int j = 1; j<=M; j++){
			cin >> mp[i][j];
		}
	}
	for(int i = 1; i<=N; i++){
		for(int j = M; j; j--){
			orb[i][j] = orb[i][j+1] + (mp[i][j] == 'O');
		}
	}
	for(int i = 1; i<=M; i++){
		for(int j = N; j; j--){
			ingot[j][i] = ingot[j+1][i] + (mp[j][i] == 'I');
		}
	}
	long long ans = 0;
	for(int i = 1; i<=N; i++){
		for(int j = 1; j<=M; j++){
			if(mp[i][j] == 'J'){
				ans += ingot[i][j] * orb[i][j];
			}
		}
	}
	cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...