Submission #438436

#TimeUsernameProblemLanguageResultExecution timeMemory
438436hibye1217Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
410 ms89836 KiB
#include <bits/stdc++.h>
#define endl '\n'
#define fr first
#define sc second
#define all(v) v.begin(),v.end()
#define unq(v) sort( all(v) ); v.erase( unique( all(v) ), v.end() )
#define bout(x) cout << bitset<sizeof(x)*8>(x) << endl
#define mkp(a,b) make_pair(a,b)
#define gcd(a,b) __gcd(a,b)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pi2 = pair<int, int>;
using pl2 = pair<ll, ll>;
using cpl = complex<ld>;
const ld pi = 3.14159265358979323846264338327950288;
const ld tau = 2 * pi;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, ddy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int nx[8] = {1, 2, 2, 1, -1, -2, -2, -1}, ny[8] = {-2, -1, 1, 2, 2, 1, -1, -2};

// #define DEBUG

string mp[3020];
int co[3020][3020], ci[3020][3020];

void Main(){
	int h, w; cin >> h >> w;
	for (int i = 0; i < h; i++){ cin >> mp[i]; }
	for (int i = 0; i < h; i++){
		for (int j = w-1; j >= 0; j--){
			co[i][j] = co[i][j+1];
			if (mp[i][j] == 'O'){ co[i][j] += 1; }
		}
	}
	for (int j = 0; j < w; j++){
		for (int i = h-1; i >= 0; i--){
			ci[i][j] = ci[i+1][j];
			if (mp[i][j] == 'I'){ ci[i][j] += 1; }
		}
	}
	ll ans = 0;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (mp[i][j] == 'J'){ ans += co[i][j] * ci[i][j]; }
		}
	}
	cout << ans;
}

int main(){
#ifndef DEBUG
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#endif
	cout.setf(ios::fixed);
	cout.precision(0);
	Main();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...