#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 + 1;
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 |
101 ms |
212056 KB |
Output is correct |
2 |
Correct |
105 ms |
212304 KB |
Output is correct |
3 |
Correct |
99 ms |
212048 KB |
Output is correct |
4 |
Correct |
88 ms |
212304 KB |
Output is correct |
5 |
Correct |
98 ms |
212336 KB |
Output is correct |
6 |
Correct |
99 ms |
212408 KB |
Output is correct |
7 |
Correct |
111 ms |
212200 KB |
Output is correct |
8 |
Correct |
98 ms |
212212 KB |
Output is correct |
9 |
Correct |
94 ms |
212236 KB |
Output is correct |
10 |
Correct |
99 ms |
212304 KB |
Output is correct |
11 |
Correct |
98 ms |
212304 KB |
Output is correct |
12 |
Correct |
94 ms |
212144 KB |
Output is correct |
13 |
Correct |
96 ms |
212448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
212056 KB |
Output is correct |
2 |
Correct |
105 ms |
212304 KB |
Output is correct |
3 |
Correct |
99 ms |
212048 KB |
Output is correct |
4 |
Correct |
88 ms |
212304 KB |
Output is correct |
5 |
Correct |
98 ms |
212336 KB |
Output is correct |
6 |
Correct |
99 ms |
212408 KB |
Output is correct |
7 |
Correct |
111 ms |
212200 KB |
Output is correct |
8 |
Correct |
98 ms |
212212 KB |
Output is correct |
9 |
Correct |
94 ms |
212236 KB |
Output is correct |
10 |
Correct |
99 ms |
212304 KB |
Output is correct |
11 |
Correct |
98 ms |
212304 KB |
Output is correct |
12 |
Correct |
94 ms |
212144 KB |
Output is correct |
13 |
Correct |
96 ms |
212448 KB |
Output is correct |
14 |
Correct |
109 ms |
213776 KB |
Output is correct |
15 |
Correct |
89 ms |
212264 KB |
Output is correct |
16 |
Correct |
100 ms |
213720 KB |
Output is correct |
17 |
Correct |
97 ms |
212312 KB |
Output is correct |
18 |
Correct |
123 ms |
213684 KB |
Output is correct |
19 |
Correct |
106 ms |
213104 KB |
Output is correct |
20 |
Correct |
108 ms |
213824 KB |
Output is correct |
21 |
Correct |
108 ms |
213856 KB |
Output is correct |
22 |
Correct |
103 ms |
213812 KB |
Output is correct |
23 |
Correct |
104 ms |
213792 KB |
Output is correct |
24 |
Correct |
108 ms |
215264 KB |
Output is correct |
25 |
Correct |
95 ms |
212864 KB |
Output is correct |
26 |
Correct |
114 ms |
213796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
212056 KB |
Output is correct |
2 |
Correct |
105 ms |
212304 KB |
Output is correct |
3 |
Correct |
99 ms |
212048 KB |
Output is correct |
4 |
Correct |
88 ms |
212304 KB |
Output is correct |
5 |
Correct |
98 ms |
212336 KB |
Output is correct |
6 |
Correct |
99 ms |
212408 KB |
Output is correct |
7 |
Correct |
111 ms |
212200 KB |
Output is correct |
8 |
Correct |
98 ms |
212212 KB |
Output is correct |
9 |
Correct |
94 ms |
212236 KB |
Output is correct |
10 |
Correct |
99 ms |
212304 KB |
Output is correct |
11 |
Correct |
98 ms |
212304 KB |
Output is correct |
12 |
Correct |
94 ms |
212144 KB |
Output is correct |
13 |
Correct |
96 ms |
212448 KB |
Output is correct |
14 |
Correct |
109 ms |
213776 KB |
Output is correct |
15 |
Correct |
89 ms |
212264 KB |
Output is correct |
16 |
Correct |
100 ms |
213720 KB |
Output is correct |
17 |
Correct |
97 ms |
212312 KB |
Output is correct |
18 |
Correct |
123 ms |
213684 KB |
Output is correct |
19 |
Correct |
106 ms |
213104 KB |
Output is correct |
20 |
Correct |
108 ms |
213824 KB |
Output is correct |
21 |
Correct |
108 ms |
213856 KB |
Output is correct |
22 |
Correct |
103 ms |
213812 KB |
Output is correct |
23 |
Correct |
104 ms |
213792 KB |
Output is correct |
24 |
Correct |
108 ms |
215264 KB |
Output is correct |
25 |
Correct |
95 ms |
212864 KB |
Output is correct |
26 |
Correct |
114 ms |
213796 KB |
Output is correct |
27 |
Execution timed out |
2387 ms |
274432 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |