Submission #1023594

#TimeUsernameProblemLanguageResultExecution timeMemory
1023594vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
107 ms157396 KiB
#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const int nmax = 3e3 + 2;
long long o[nmax][nmax], I[nmax][nmax], h, w, ans;
string s[nmax];

int main(){
	faster
	cin >> h >> w;
	for(int i = 1; i <= h; i++){
		cin >> s[i];
		s[i] = " " + s[i];
	}
	for(int i = h; i >= 1; i--){
		for(int j = w; j >= 1; j--){
			o[i][j] = o[i][j + 1] + (s[i][j] == 'O');
			I[i][j] = I[i + 1][j] + (s[i][j] == 'I');
			if(s[i][j] == 'J')ans += o[i][j]*I[i][j];
		}
	}
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...