Submission #1023902

#TimeUsernameProblemLanguageResultExecution timeMemory
1023902vux2codeBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
148 ms159060 KiB
// Src : Vux2Code
#include <bits/stdc++.h>
#define pq_rvs pll,vector<pll>,greater<pll>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

const ll maxN = 3e3 + 5, inf64 = 1e18, mod = 1e9 + 7, maxLog = 20;
ll t = 1;

ll n, m, Iunder [maxN] [maxN], Oright [maxN] [maxN], ans;
char a [maxN] [maxN];

void solve () {
    cin >> n >> m;
	for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++) cin >> a [i] [j];
	for (int i = n; i >= 1; i --) for (int j = m; j >= 1; j --) {
		Iunder [i] [j] = Iunder [i + 1] [j] + (a [i] [j] == 'I');
		Oright [i] [j] = Oright [i] [j + 1] + (a [i] [j] == 'O');
		ans += (a [i] [j] == 'J') * Iunder [i] [j] * Oright [i] [j];
	}
	cout << ans;
	
}

int main (){
	ios::sync_with_stdio (0);
	cin. tie (0);
	cout. tie (0);
	//freopen (".inp", "r", stdin);
	//freopen (".out", "w", stdout);
	//cin >> t;
    while (t --) solve ();
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...