Submission #1062340

#TimeUsernameProblemLanguageResultExecution timeMemory
1062340ducksaysquackBitaro the Brave (JOI19_ho_t1)C++98
100 / 100
307 ms161768 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n, k; cin >> n >> k; vector<string> v(n);
	for(int i=0;i<n;i++) cin >> v[i];
	vector<vector<int>> a(n, vector<int>(k)), b(n, vector<int>(k));
	for(int i=0;i<n;i++) for(int j=0;j<k;j++) {
		if(v[i][j] == 'O') a[i][j]++;
		if(j) a[i][j] += a[i][j-1];
	}
	for(int j=0;j<k;j++) for(int i=0;i<n;i++) {
		if(v[i][j] == 'I') b[i][j]++;
		if(i) b[i][j] += b[i-1][j];
	}
	int ans = 0;
	for(int i=0;i<n;i++) for(int j=0;j<k;j++) if(v[i][j] == 'J') ans += (b[n-1][j]-b[i][j])*(a[i][k-1]-a[i][j]);
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...