Submission #1203803

#TimeUsernameProblemLanguageResultExecution timeMemory
1203803chawinknBitaro the Brave (JOI19_ho_t1)C++20
20 / 100
3 ms2704 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int h, w;
	cin >> h >> w;
	vector<string> s(h+1);
	vector<vector<int>> O(h+1, vector<int>(w+1)), I(h+1, vector<int>(w+1));
	for (int i = 1; i <= h; i++) {
		cin >> s[i];
		s[i] = ' '+s[i];
		for (int j = 1; j <= w; j++) {
			O[i][j] = O[i][j-1]+(s[i][j] == 'O');
			I[i][j] = I[i-1][j]+(s[i][j] == 'I');
		}
	}
	int ans=0;
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			if (s[i][j] == 'J')
				ans += (O[i][w]-O[i][j])*(I[h][j]-I[i][j]);
	cout << ans;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...