This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
void solve() {
int n,m; cin >> n >> m;
vector<vector<int>> ingot(n, vector<int>(m)), orb(n, vector<int>(m));
vector<vector<char>> grid(n, vector<char>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> grid[i][j];
if (grid[i][j] == 'I') ingot[i][j]++;
if (grid[i][j] == 'O') orb[i][j]++;
}
}
for (int j = 0;j < m; j++) {
for(int i=n-2;i>=0;i--){
ingot[i][j] += ingot[i+1][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = m - 2; j >= 0; j--) {
orb[i][j] += orb[i][j + 1];
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (grid[i][j] == 'J') {
ans += ingot[i][j] * orb[i][j];
}
}
}
cout << ans << '\n';
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |