Submission #1226689

#TimeUsernameProblemLanguageResultExecution timeMemory
1226689wedonttalkanymoreBitaro the Brave (JOI19_ho_t1)C++20
20 / 100
125 ms11396 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll N = 5005, inf = 1e9;

int h, w;
int a[N][N];
ll pfs[N][N][3]; 

signed main() {
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		string s;
		cin >> s;
		for (int j = 1; j <= w; j++) {
			if (s[j - 1] == 'J') a[i][j] = 0;
			else if (s[j - 1] == 'O') a[i][j] = 1;
			else a[i][j] = 2;
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			for (int k = 0; k < 3; k++) {
				pfs[i][j][k] = pfs[i][j - 1][k];
				if (a[i][j] == k) pfs[i][j][k]++;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			for (int k = i + 1; k <= h; k++) {
//				for (int l = j + 1; l <= w; l++) {
					if (a[i][j] == 0 && a[k][j] == 2) ans += pfs[i][w][1] - pfs[i][j][1];
//				}
			}
		}
	}
	cout << ans;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...