Submission #717242

#TimeUsernameProblemLanguageResultExecution timeMemory
717242JuanBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
624 ms9696 KiB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ff first
#define ss second
#define int long long
#define all(x) x.begin(), x.end()
const int maxn = 3e3 + 5;

int va[maxn];
char mtx[maxn][maxn];

int32_t main(){
	int h, w; cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> mtx[i][j];
		}
	}

	int ans = 0;
	for(int i = 0; i < w; i++){
		for(int j = h-1; j >= 0; j--){
			if(mtx[j][i]=='O') ans += va[j];
		}

		int ingots = 0;
		for(int j = h-1; j >= 0; j--){
			if(mtx[j][i]=='I') ingots++;
			else if(mtx[j][i]=='J') va[j] += ingots;
		}
	}

	cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...