Submission #769718

#TimeUsernameProblemLanguageResultExecution timeMemory
769718Gabi88Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
328 ms159304 KiB
#include<bits/stdc++.h>
using namespace std;

#define LL long long

LL n, m, br, lo[3009][3009], li[3009][3009];
char zad[3009][3009];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m;
	for(int i=0; i<n; i++)   for(int j=0; j<m; j++)  cin >> zad[i][j];
	for(int i=0; i<n; i++){
		br = 0;
		for(int j=m-1; j >= 0; j--){
			if (zad[i][j] == 'O') br++;
			lo[i][j] = br;
		}
	}
	for(int j=0; j<m; j++){
		br = 0;
		for(int i=n-1; i >= 0; i--){
			if (zad[i][j] == 'I') br++;
			li[i][j] = br;
		}
	}
	br = 0;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if (zad[i][j] == 'J') br += lo[i][j] * li[i][j];
		}
	}
	cout << br; return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...