#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;
const int N = 3e3 + 1;
int a[N][N], b[N][N];
char gr[N][N];
signed main()
{
int h, w; cin >> h >> w;
vpii J(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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
5464 KB |
Output is correct |
6 |
Correct |
2 ms |
5212 KB |
Output is correct |
7 |
Correct |
2 ms |
5468 KB |
Output is correct |
8 |
Correct |
2 ms |
5628 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5464 KB |
Output is correct |
11 |
Correct |
2 ms |
5468 KB |
Output is correct |
12 |
Correct |
2 ms |
5212 KB |
Output is correct |
13 |
Correct |
2 ms |
5464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
5464 KB |
Output is correct |
6 |
Correct |
2 ms |
5212 KB |
Output is correct |
7 |
Correct |
2 ms |
5468 KB |
Output is correct |
8 |
Correct |
2 ms |
5628 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5464 KB |
Output is correct |
11 |
Correct |
2 ms |
5468 KB |
Output is correct |
12 |
Correct |
2 ms |
5212 KB |
Output is correct |
13 |
Correct |
2 ms |
5464 KB |
Output is correct |
14 |
Correct |
10 ms |
21304 KB |
Output is correct |
15 |
Correct |
3 ms |
14684 KB |
Output is correct |
16 |
Correct |
11 ms |
13624 KB |
Output is correct |
17 |
Correct |
1 ms |
600 KB |
Output is correct |
18 |
Correct |
14 ms |
22068 KB |
Output is correct |
19 |
Correct |
10 ms |
21028 KB |
Output is correct |
20 |
Correct |
17 ms |
21824 KB |
Output is correct |
21 |
Correct |
13 ms |
22068 KB |
Output is correct |
22 |
Correct |
11 ms |
22072 KB |
Output is correct |
23 |
Correct |
15 ms |
21812 KB |
Output is correct |
24 |
Correct |
13 ms |
22360 KB |
Output is correct |
25 |
Correct |
11 ms |
21036 KB |
Output is correct |
26 |
Correct |
13 ms |
21816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
5464 KB |
Output is correct |
6 |
Correct |
2 ms |
5212 KB |
Output is correct |
7 |
Correct |
2 ms |
5468 KB |
Output is correct |
8 |
Correct |
2 ms |
5628 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5464 KB |
Output is correct |
11 |
Correct |
2 ms |
5468 KB |
Output is correct |
12 |
Correct |
2 ms |
5212 KB |
Output is correct |
13 |
Correct |
2 ms |
5464 KB |
Output is correct |
14 |
Correct |
10 ms |
21304 KB |
Output is correct |
15 |
Correct |
3 ms |
14684 KB |
Output is correct |
16 |
Correct |
11 ms |
13624 KB |
Output is correct |
17 |
Correct |
1 ms |
600 KB |
Output is correct |
18 |
Correct |
14 ms |
22068 KB |
Output is correct |
19 |
Correct |
10 ms |
21028 KB |
Output is correct |
20 |
Correct |
17 ms |
21824 KB |
Output is correct |
21 |
Correct |
13 ms |
22068 KB |
Output is correct |
22 |
Correct |
11 ms |
22072 KB |
Output is correct |
23 |
Correct |
15 ms |
21812 KB |
Output is correct |
24 |
Correct |
13 ms |
22360 KB |
Output is correct |
25 |
Correct |
11 ms |
21036 KB |
Output is correct |
26 |
Correct |
13 ms |
21816 KB |
Output is correct |
27 |
Correct |
279 ms |
194752 KB |
Output is correct |
28 |
Correct |
17 ms |
72336 KB |
Output is correct |
29 |
Correct |
31 ms |
22020 KB |
Output is correct |
30 |
Correct |
2 ms |
1112 KB |
Output is correct |
31 |
Correct |
184 ms |
161176 KB |
Output is correct |
32 |
Correct |
201 ms |
165224 KB |
Output is correct |
33 |
Correct |
253 ms |
196556 KB |
Output is correct |
34 |
Correct |
203 ms |
184628 KB |
Output is correct |
35 |
Correct |
228 ms |
197424 KB |
Output is correct |
36 |
Correct |
236 ms |
197016 KB |
Output is correct |
37 |
Correct |
291 ms |
207736 KB |
Output is correct |
38 |
Correct |
172 ms |
138688 KB |
Output is correct |
39 |
Correct |
194 ms |
160584 KB |
Output is correct |