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;
typedef long long int64;
const int maxn = 3e3 + 2;
string a [maxn];
int64 row [maxn][maxn], col[maxn][maxn];
int main() {
int n,m;
cin >> n >> m;
for (int i = 1; i <= n; i++){
cin >> a[i];
a[i] = "#" + a[i];
for (int j = 1; j <= m; j++){
row[i][j] = row[i][j-1] + (a[i][j] == 'O');
}
}
for (int j = 1; j <= m; j++){
for (int i = 1; i <= n; i++){
col[j][i] = col[j][i-1] + (a[i][j] == 'I');
}
}
int64 rs = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
// cout << i << " " << j << " " << (row[i][n] - row[i][j]) << " " << (col[j][n] - col[j][i]) << "\n";
if (a[i][j] == 'J') rs+=(row[i][m] - row[i][j]) * (col[j][n] - col[j][i]);
}
}
cout << rs << "\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... |