Submission #878252

#TimeUsernameProblemLanguageResultExecution timeMemory
878252dsyzBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
224 ms18000 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll H,W;
	cin>>H>>W;
	char arr[H][W];
	ll row[H]; //number of unvisited orbs in row i
	ll col[W]; //number of unvisited ingots in col j
	memset(row,0,sizeof(row));
	memset(col,0,sizeof(col));
	for(ll i = 0;i < H;i++){
		for(ll j = 0;j < W;j++){
			cin>>arr[i][j];
			if(arr[i][j] == 'O') row[i]++;
			if(arr[i][j] == 'I') col[j]++;
		}
	}
	ll sum = 0;
	for(ll i = 0;i < H;i++){
		for(ll j = 0;j < W;j++){
			if(arr[i][j] == 'J'){
				sum += row[i] * col[j];
			}else if(arr[i][j] == 'O'){
				row[i]--;
			}else if(arr[i][j] == 'I'){
				col[j]--;
			}
		}
	}
	cout<<sum<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...