#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 + 20;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
214920 KB |
Output is correct |
2 |
Correct |
106 ms |
214864 KB |
Output is correct |
3 |
Correct |
110 ms |
214984 KB |
Output is correct |
4 |
Correct |
118 ms |
214996 KB |
Output is correct |
5 |
Correct |
102 ms |
215104 KB |
Output is correct |
6 |
Correct |
112 ms |
215072 KB |
Output is correct |
7 |
Correct |
109 ms |
215000 KB |
Output is correct |
8 |
Correct |
119 ms |
215140 KB |
Output is correct |
9 |
Correct |
95 ms |
215036 KB |
Output is correct |
10 |
Correct |
115 ms |
215104 KB |
Output is correct |
11 |
Correct |
115 ms |
215176 KB |
Output is correct |
12 |
Correct |
109 ms |
214920 KB |
Output is correct |
13 |
Correct |
123 ms |
214892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
214920 KB |
Output is correct |
2 |
Correct |
106 ms |
214864 KB |
Output is correct |
3 |
Correct |
110 ms |
214984 KB |
Output is correct |
4 |
Correct |
118 ms |
214996 KB |
Output is correct |
5 |
Correct |
102 ms |
215104 KB |
Output is correct |
6 |
Correct |
112 ms |
215072 KB |
Output is correct |
7 |
Correct |
109 ms |
215000 KB |
Output is correct |
8 |
Correct |
119 ms |
215140 KB |
Output is correct |
9 |
Correct |
95 ms |
215036 KB |
Output is correct |
10 |
Correct |
115 ms |
215104 KB |
Output is correct |
11 |
Correct |
115 ms |
215176 KB |
Output is correct |
12 |
Correct |
109 ms |
214920 KB |
Output is correct |
13 |
Correct |
123 ms |
214892 KB |
Output is correct |
14 |
Correct |
116 ms |
216436 KB |
Output is correct |
15 |
Correct |
115 ms |
214868 KB |
Output is correct |
16 |
Correct |
121 ms |
216504 KB |
Output is correct |
17 |
Correct |
108 ms |
214884 KB |
Output is correct |
18 |
Correct |
108 ms |
216616 KB |
Output is correct |
19 |
Correct |
129 ms |
215488 KB |
Output is correct |
20 |
Correct |
115 ms |
216564 KB |
Output is correct |
21 |
Correct |
109 ms |
216424 KB |
Output is correct |
22 |
Correct |
109 ms |
216524 KB |
Output is correct |
23 |
Correct |
129 ms |
216600 KB |
Output is correct |
24 |
Correct |
110 ms |
219164 KB |
Output is correct |
25 |
Correct |
116 ms |
215960 KB |
Output is correct |
26 |
Correct |
123 ms |
216544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
214920 KB |
Output is correct |
2 |
Correct |
106 ms |
214864 KB |
Output is correct |
3 |
Correct |
110 ms |
214984 KB |
Output is correct |
4 |
Correct |
118 ms |
214996 KB |
Output is correct |
5 |
Correct |
102 ms |
215104 KB |
Output is correct |
6 |
Correct |
112 ms |
215072 KB |
Output is correct |
7 |
Correct |
109 ms |
215000 KB |
Output is correct |
8 |
Correct |
119 ms |
215140 KB |
Output is correct |
9 |
Correct |
95 ms |
215036 KB |
Output is correct |
10 |
Correct |
115 ms |
215104 KB |
Output is correct |
11 |
Correct |
115 ms |
215176 KB |
Output is correct |
12 |
Correct |
109 ms |
214920 KB |
Output is correct |
13 |
Correct |
123 ms |
214892 KB |
Output is correct |
14 |
Correct |
116 ms |
216436 KB |
Output is correct |
15 |
Correct |
115 ms |
214868 KB |
Output is correct |
16 |
Correct |
121 ms |
216504 KB |
Output is correct |
17 |
Correct |
108 ms |
214884 KB |
Output is correct |
18 |
Correct |
108 ms |
216616 KB |
Output is correct |
19 |
Correct |
129 ms |
215488 KB |
Output is correct |
20 |
Correct |
115 ms |
216564 KB |
Output is correct |
21 |
Correct |
109 ms |
216424 KB |
Output is correct |
22 |
Correct |
109 ms |
216524 KB |
Output is correct |
23 |
Correct |
129 ms |
216600 KB |
Output is correct |
24 |
Correct |
110 ms |
219164 KB |
Output is correct |
25 |
Correct |
116 ms |
215960 KB |
Output is correct |
26 |
Correct |
123 ms |
216544 KB |
Output is correct |
27 |
Correct |
385 ms |
263844 KB |
Output is correct |
28 |
Correct |
119 ms |
215468 KB |
Output is correct |
29 |
Correct |
134 ms |
222700 KB |
Output is correct |
30 |
Correct |
115 ms |
215088 KB |
Output is correct |
31 |
Correct |
265 ms |
264840 KB |
Output is correct |
32 |
Correct |
315 ms |
239364 KB |
Output is correct |
33 |
Correct |
364 ms |
264328 KB |
Output is correct |
34 |
Correct |
300 ms |
263780 KB |
Output is correct |
35 |
Correct |
329 ms |
263912 KB |
Output is correct |
36 |
Correct |
342 ms |
264444 KB |
Output is correct |
37 |
Runtime error |
326 ms |
274432 KB |
Execution killed with signal 9 |
38 |
Halted |
0 ms |
0 KB |
- |