This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// https://noic.com.br/materiais-informatica/problemas-da-semana/intermediario-semana36/ > página 13
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int h, w; cin >> h >> w;
vector<vector<char>> grid (h, vector<char> (w));
vector<vector<int>> pfI (h, vector<int> (w));
vector<vector<int>> pfO (h, vector<int> (w));
for (int i=0; i<h; i++) {
string l; cin >> l;
for (int j=0; j<w; j++) grid[i][j] = l[j];
}
for (int i=0; i<h; i++) {
int cnt = 0;
for (int j=w-1; j>=0; j--) {
if (grid[i][j] == 'O') cnt++;
pfO[i][j] = cnt;
}
}
for (int j=0; j<w; j++) {
int cnt = 0;
for (int i=h-1; i>=0; i--) {
if (grid[i][j] == 'I') cnt++;
pfI[i][j] = cnt;
}
}
ll ans = 0;
for (int i=0; i<h; i++) {
for (int j=0; j<w; j++) {
if (grid[i][j] == 'J') {
ans += pfO[i][j] * pfI[i][j];
}
}
}
cout << ans << endl;
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... |