Submission #209198

#TimeUsernameProblemLanguageResultExecution timeMemory
209198kostia244Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
240 ms80504 KiB
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn= 3030;
int n, m;
char mat[maxn][maxn];
int J[maxn][maxn], I[maxn][maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> mat[i][j];
	for(int i = 1; i <= n; i++) {
		for(int j = m; j; j--) {
			J[i][j] = J[i][j+1] + (mat[i][j] == 'O');
		}
	}
	for(int i = n; i; i--) {
		for(int j = 1; j <= m; j++) {
			I[i][j] = I[i+1][j] + (mat[i][j] == 'I');
		}
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) {
			if(mat[i][j] != 'J') continue;
			ans += J[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...