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>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int h, w;
cin >> h >> w;
vector<vector<char>> grid(h+1, vector<char>(w+1));
vector<int> orb(h+1), ingot(w+1);
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
cin >> grid[i][j];
if (grid[i][j] == 'O')
orb[i]++;
else if (grid[i][j] == 'I')
ingot[j]++;
}
}
int ans = 0;
vector<int> rcnt(h+1), ccnt(w+1);
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
if (grid[i][j] == 'J')
ans += (orb[i]-rcnt[i])*(ingot[j]-ccnt[j]);
else if (grid[i][j] == 'O')
rcnt[i]++;
else
ccnt[j]++;
}
}
cout << ans << '\n';
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... |