#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 |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1644 KB |
Output is correct |
6 |
Correct |
2 ms |
1644 KB |
Output is correct |
7 |
Incorrect |
2 ms |
1516 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1644 KB |
Output is correct |
6 |
Correct |
2 ms |
1644 KB |
Output is correct |
7 |
Incorrect |
2 ms |
1516 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1644 KB |
Output is correct |
6 |
Correct |
2 ms |
1644 KB |
Output is correct |
7 |
Incorrect |
2 ms |
1516 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |