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>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long
#define nl '\n'
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
mt19937 rng((unsigned)chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1000000007, mod2 = 998244353;
// change this
const int N = 3005;
int n, m, ao[N][N], ai[N][N], ans;
char arr[N][N];
signed main() {
io;
cin >> n >> m;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
cin >> arr[i][j];
if (arr[i][j] == 'O') ao[i][j]++;
else if (arr[i][j] == 'I') ai[i][j]++;
ao[i][j] += ao[i][j-1];
ai[i][j] += ai[i-1][j];
}
}
for (int i=1; i<=n; i++) {
for (int j=1; j<=n; j++) {
if (arr[i][j] != 'J') continue;
int x = ao[i][m] - ao[i][j], y = ai[n][j] - ai[i][j];
ans += x * y;
}
}
cout << ans << nl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |