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;
#define int long long
void Solve() {
int h, w;
cin >> h >> w;
char a[h][w];
for(int i = 0; i < h; i++) {
for(int j = 0; j < w; j++) {
cin >> a[i][j];
}
}
int orbRow[h], ingotCol[w];
for(int i = 0; i < h; i++) {
orbRow[i] = 0;
}
for(int i = 0; i < w; i++) {
ingotCol[i] = 0;
}
for(int i = 0; i < h; i++) {
for(int j = 0; j < w; j++) {
if(a[i][j] == 'O') {
orbRow[i]++;
}
if(a[i][j] == 'I') {
ingotCol[j]++;
}
}
}
int ans = 0;
for(int i = 0; i < h; i++) {
for(int j = 0; j < w; j++) {
if(a[i][j] == 'J') {
ans += orbRow[i] * ingotCol[j];
}
else if(a[i][j] == 'O') {
orbRow[i]--;
}
else {
ingotCol[j]--;
}
}
}
cout << ans << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
Solve();
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... |