#include <bits/stdc++.h>
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
int N = 3e3 + 7;
signed main()
{
int h, w; cin >> h >> w;
vii a(N, vi(N)), b(N, vi(N));
vpii J(N);
vii gr(N, vi(N));
for (int i = 1; i <= h; i++)
{
string s; cin >> s;
s = "$" + s;
for (int j = 1; j <= w; j++)
{
gr[i][j] = s[j];
if (s[j] == 'J') J.pb({i, j});
}
}
for (int i = h; i >= 1; i--)
{
for (int j = w; j >= 1; j--)
{
a[i][j] = a[i][j + 1] + (gr[i][j] == 'O');
b[i][j] = b[i + 1][j] + (gr[i][j] == 'I');
}
}
int ans = 0;
for (auto [i, j] : J)
{
ans += a[i][j] * b[i][j];
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
213116 KB |
Output is correct |
2 |
Correct |
97 ms |
213156 KB |
Output is correct |
3 |
Correct |
103 ms |
213072 KB |
Output is correct |
4 |
Correct |
108 ms |
213152 KB |
Output is correct |
5 |
Correct |
110 ms |
213280 KB |
Output is correct |
6 |
Correct |
106 ms |
213100 KB |
Output is correct |
7 |
Correct |
98 ms |
213268 KB |
Output is correct |
8 |
Correct |
104 ms |
213080 KB |
Output is correct |
9 |
Correct |
98 ms |
212960 KB |
Output is correct |
10 |
Correct |
94 ms |
213124 KB |
Output is correct |
11 |
Correct |
87 ms |
213164 KB |
Output is correct |
12 |
Correct |
95 ms |
213200 KB |
Output is correct |
13 |
Correct |
98 ms |
213296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
213116 KB |
Output is correct |
2 |
Correct |
97 ms |
213156 KB |
Output is correct |
3 |
Correct |
103 ms |
213072 KB |
Output is correct |
4 |
Correct |
108 ms |
213152 KB |
Output is correct |
5 |
Correct |
110 ms |
213280 KB |
Output is correct |
6 |
Correct |
106 ms |
213100 KB |
Output is correct |
7 |
Correct |
98 ms |
213268 KB |
Output is correct |
8 |
Correct |
104 ms |
213080 KB |
Output is correct |
9 |
Correct |
98 ms |
212960 KB |
Output is correct |
10 |
Correct |
94 ms |
213124 KB |
Output is correct |
11 |
Correct |
87 ms |
213164 KB |
Output is correct |
12 |
Correct |
95 ms |
213200 KB |
Output is correct |
13 |
Correct |
98 ms |
213296 KB |
Output is correct |
14 |
Correct |
101 ms |
214660 KB |
Output is correct |
15 |
Correct |
94 ms |
213076 KB |
Output is correct |
16 |
Correct |
115 ms |
214536 KB |
Output is correct |
17 |
Correct |
113 ms |
213172 KB |
Output is correct |
18 |
Correct |
102 ms |
214536 KB |
Output is correct |
19 |
Correct |
108 ms |
213740 KB |
Output is correct |
20 |
Correct |
100 ms |
214604 KB |
Output is correct |
21 |
Correct |
119 ms |
214668 KB |
Output is correct |
22 |
Correct |
115 ms |
214676 KB |
Output is correct |
23 |
Correct |
108 ms |
214644 KB |
Output is correct |
24 |
Correct |
101 ms |
216092 KB |
Output is correct |
25 |
Correct |
107 ms |
213848 KB |
Output is correct |
26 |
Correct |
113 ms |
214492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
213116 KB |
Output is correct |
2 |
Correct |
97 ms |
213156 KB |
Output is correct |
3 |
Correct |
103 ms |
213072 KB |
Output is correct |
4 |
Correct |
108 ms |
213152 KB |
Output is correct |
5 |
Correct |
110 ms |
213280 KB |
Output is correct |
6 |
Correct |
106 ms |
213100 KB |
Output is correct |
7 |
Correct |
98 ms |
213268 KB |
Output is correct |
8 |
Correct |
104 ms |
213080 KB |
Output is correct |
9 |
Correct |
98 ms |
212960 KB |
Output is correct |
10 |
Correct |
94 ms |
213124 KB |
Output is correct |
11 |
Correct |
87 ms |
213164 KB |
Output is correct |
12 |
Correct |
95 ms |
213200 KB |
Output is correct |
13 |
Correct |
98 ms |
213296 KB |
Output is correct |
14 |
Correct |
101 ms |
214660 KB |
Output is correct |
15 |
Correct |
94 ms |
213076 KB |
Output is correct |
16 |
Correct |
115 ms |
214536 KB |
Output is correct |
17 |
Correct |
113 ms |
213172 KB |
Output is correct |
18 |
Correct |
102 ms |
214536 KB |
Output is correct |
19 |
Correct |
108 ms |
213740 KB |
Output is correct |
20 |
Correct |
100 ms |
214604 KB |
Output is correct |
21 |
Correct |
119 ms |
214668 KB |
Output is correct |
22 |
Correct |
115 ms |
214676 KB |
Output is correct |
23 |
Correct |
108 ms |
214644 KB |
Output is correct |
24 |
Correct |
101 ms |
216092 KB |
Output is correct |
25 |
Correct |
107 ms |
213848 KB |
Output is correct |
26 |
Correct |
113 ms |
214492 KB |
Output is correct |
27 |
Correct |
345 ms |
262376 KB |
Output is correct |
28 |
Correct |
93 ms |
213472 KB |
Output is correct |
29 |
Correct |
116 ms |
219880 KB |
Output is correct |
30 |
Correct |
96 ms |
213180 KB |
Output is correct |
31 |
Correct |
291 ms |
263160 KB |
Output is correct |
32 |
Correct |
314 ms |
237484 KB |
Output is correct |
33 |
Correct |
353 ms |
262264 KB |
Output is correct |
34 |
Correct |
306 ms |
262008 KB |
Output is correct |
35 |
Correct |
410 ms |
262396 KB |
Output is correct |
36 |
Correct |
330 ms |
262296 KB |
Output is correct |
37 |
Runtime error |
290 ms |
274432 KB |
Execution killed with signal 9 |
38 |
Halted |
0 ms |
0 KB |
- |