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
int ps1[3010][3010]; // O
int ps2[3010][3010]; // I
char a[3010][3010];
signed main() {
int H, W; cin >> H >> W;
for(int i=1; i<=H; i++) {
for(int j=1; j<=W; j++) {
cin >> a[i][j];
ps1[i][j] = ps1[i][j-1] + (a[i][j] == 'O');
ps2[i][j] = ps2[i-1][j] + (a[i][j] == 'I');
}
}
int ans = 0;
for(int i=1; i<=H; i++) {
for(int j=1; j<=W; j++) {
if(a[i][j] == 'J') ans += (ps1[i][W] - ps1[i][j]) * (ps2[H][j] - ps2[i][j]);
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |