#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#define ll long long
#define ld long double
#define eps 1e-8
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
// change if necessary
#define MAXN 3010
using namespace std;
int h, w;
string grid[MAXN];
ll ans;
int ocnt[MAXN][MAXN];
int icnt[MAXN][MAXN];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> h >> w;
for (int i = 0; i < h; i++) {
cin >> grid[i];
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
ocnt[i][j] = ocnt[i][j + 1];
if (grid[i][j] == 'O') ocnt[i][j]++;
}
}
for (int j = 0; j < w; j++) {
for (int i = h - 1; i >= 0; i--) {
icnt[i][j] = icnt[i + 1][j];
if (grid[i][j] == 'I') icnt[i][j]++;
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (grid[i][j] == 'J') {
ans += (ll) ocnt[i][j] * icnt[i][j];
}
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1388 KB |
Output is correct |
6 |
Correct |
1 ms |
1260 KB |
Output is correct |
7 |
Correct |
1 ms |
1260 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
1 ms |
1260 KB |
Output is correct |
11 |
Correct |
1 ms |
1388 KB |
Output is correct |
12 |
Correct |
1 ms |
1260 KB |
Output is correct |
13 |
Correct |
2 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1388 KB |
Output is correct |
6 |
Correct |
1 ms |
1260 KB |
Output is correct |
7 |
Correct |
1 ms |
1260 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
1 ms |
1260 KB |
Output is correct |
11 |
Correct |
1 ms |
1388 KB |
Output is correct |
12 |
Correct |
1 ms |
1260 KB |
Output is correct |
13 |
Correct |
2 ms |
1260 KB |
Output is correct |
14 |
Correct |
8 ms |
6304 KB |
Output is correct |
15 |
Correct |
3 ms |
3820 KB |
Output is correct |
16 |
Correct |
4 ms |
3820 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
10 ms |
6892 KB |
Output is correct |
19 |
Correct |
9 ms |
6764 KB |
Output is correct |
20 |
Correct |
6 ms |
6764 KB |
Output is correct |
21 |
Correct |
9 ms |
6892 KB |
Output is correct |
22 |
Correct |
12 ms |
6764 KB |
Output is correct |
23 |
Correct |
8 ms |
6764 KB |
Output is correct |
24 |
Correct |
10 ms |
6892 KB |
Output is correct |
25 |
Correct |
6 ms |
6764 KB |
Output is correct |
26 |
Correct |
6 ms |
6764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1388 KB |
Output is correct |
6 |
Correct |
1 ms |
1260 KB |
Output is correct |
7 |
Correct |
1 ms |
1260 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
1 ms |
1260 KB |
Output is correct |
11 |
Correct |
1 ms |
1388 KB |
Output is correct |
12 |
Correct |
1 ms |
1260 KB |
Output is correct |
13 |
Correct |
2 ms |
1260 KB |
Output is correct |
14 |
Correct |
8 ms |
6304 KB |
Output is correct |
15 |
Correct |
3 ms |
3820 KB |
Output is correct |
16 |
Correct |
4 ms |
3820 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
10 ms |
6892 KB |
Output is correct |
19 |
Correct |
9 ms |
6764 KB |
Output is correct |
20 |
Correct |
6 ms |
6764 KB |
Output is correct |
21 |
Correct |
9 ms |
6892 KB |
Output is correct |
22 |
Correct |
12 ms |
6764 KB |
Output is correct |
23 |
Correct |
8 ms |
6764 KB |
Output is correct |
24 |
Correct |
10 ms |
6892 KB |
Output is correct |
25 |
Correct |
6 ms |
6764 KB |
Output is correct |
26 |
Correct |
6 ms |
6764 KB |
Output is correct |
27 |
Correct |
314 ms |
88556 KB |
Output is correct |
28 |
Correct |
12 ms |
19308 KB |
Output is correct |
29 |
Correct |
11 ms |
7916 KB |
Output is correct |
30 |
Correct |
1 ms |
748 KB |
Output is correct |
31 |
Correct |
232 ms |
72044 KB |
Output is correct |
32 |
Correct |
282 ms |
89728 KB |
Output is correct |
33 |
Correct |
286 ms |
89324 KB |
Output is correct |
34 |
Correct |
268 ms |
83564 KB |
Output is correct |
35 |
Correct |
288 ms |
89580 KB |
Output is correct |
36 |
Correct |
276 ms |
89580 KB |
Output is correct |
37 |
Correct |
345 ms |
89580 KB |
Output is correct |
38 |
Correct |
195 ms |
72036 KB |
Output is correct |
39 |
Correct |
187 ms |
71788 KB |
Output is correct |