제출 #110386

#제출 시각아이디문제언어결과실행 시간메모리
110386thiago4532Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
507 ms71244 KiB
#include <bits/stdc++.h>
#define int int64_t
#define J 0
#define O 1
#define I 2

using namespace std;
const int maxn = 3e3 + 10;
int mat[maxn][maxn];
int linha[maxn], coluna[maxn];

int32_t main() {
	int n, m;
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		string str;
		cin >> str;
		for(int j = 1; j <= m; j++) {
			if(str[j-1] == 'J') mat[i][j] = J;
			else if(str[j-1] == 'O') mat[i][j] = O;
			else if(str[j-1] == 'I') mat[i][j] = I;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			linha[i] += (mat[i][j] == O);
			coluna[j] += (mat[i][j] == I);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(mat[i][j] == O) linha[i]--;
			else if(mat[i][j] == I) coluna[j]--;
			else if(mat[i][j] == J)
				ans += linha[i]*coluna[j];
		}
	}
	cout << ans << "\n";
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...