This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
__author__ : FireGhost
problems_ID: JOI19_ho_t1
*/
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
const int N = 3000 + 3;
const int MOD = 1e9 + 7;
int n, m, row_prf[N][N], col_prf[N][N];
char c[N][N];
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> c[i][j];
row_prf[i][j] = row_prf[i][j - 1] + (c[i][j] == 'O');
col_prf[i][j] = col_prf[i - 1][j] + (c[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (c[i][j] == 'J')
ans += (row_prf[i][m] - row_prf[i][j]) * (col_prf[n][j] - col_prf[i][j]);
}
}
cout << ans;
}
int main() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int t = 1;
while (t--)
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... |