#include <bits/stdc++.h>
using namespace std;
long long h, w;
vector<string> board;
vector<long long> row, col;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> h >> w;
board.resize(h+1);
row.resize(h+1);
col.resize(w+1);
for (long long i = 1; i <= h; i++) {
cin >> board[i];
for(long long j=1; j <= w; j++) {
if(board[i][j-1]=='O')
{
row[i]++;
}
else if(board[i][j-1]=='I')
{
col[j]++;
}
}
}
long long ans = 0;
for(long long i = 1; i <= h; i++) {
for(long long j = 1; j <= w; j++) {
if(board[i][j-1] == 'J') {
ans += row[i]*col[j];
}
}
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |