#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;
}
Compilation message
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:47:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
47 | for (auto [i, j] : J)
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
214976 KB |
Output is correct |
2 |
Correct |
95 ms |
214868 KB |
Output is correct |
3 |
Correct |
86 ms |
214996 KB |
Output is correct |
4 |
Correct |
96 ms |
214908 KB |
Output is correct |
5 |
Correct |
101 ms |
215184 KB |
Output is correct |
6 |
Correct |
88 ms |
215056 KB |
Output is correct |
7 |
Correct |
93 ms |
214920 KB |
Output is correct |
8 |
Correct |
92 ms |
214976 KB |
Output is correct |
9 |
Correct |
91 ms |
215020 KB |
Output is correct |
10 |
Correct |
94 ms |
214912 KB |
Output is correct |
11 |
Correct |
93 ms |
215120 KB |
Output is correct |
12 |
Correct |
89 ms |
214864 KB |
Output is correct |
13 |
Correct |
97 ms |
215116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
214976 KB |
Output is correct |
2 |
Correct |
95 ms |
214868 KB |
Output is correct |
3 |
Correct |
86 ms |
214996 KB |
Output is correct |
4 |
Correct |
96 ms |
214908 KB |
Output is correct |
5 |
Correct |
101 ms |
215184 KB |
Output is correct |
6 |
Correct |
88 ms |
215056 KB |
Output is correct |
7 |
Correct |
93 ms |
214920 KB |
Output is correct |
8 |
Correct |
92 ms |
214976 KB |
Output is correct |
9 |
Correct |
91 ms |
215020 KB |
Output is correct |
10 |
Correct |
94 ms |
214912 KB |
Output is correct |
11 |
Correct |
93 ms |
215120 KB |
Output is correct |
12 |
Correct |
89 ms |
214864 KB |
Output is correct |
13 |
Correct |
97 ms |
215116 KB |
Output is correct |
14 |
Correct |
92 ms |
216408 KB |
Output is correct |
15 |
Correct |
97 ms |
215084 KB |
Output is correct |
16 |
Correct |
101 ms |
216584 KB |
Output is correct |
17 |
Correct |
101 ms |
215000 KB |
Output is correct |
18 |
Correct |
106 ms |
216492 KB |
Output is correct |
19 |
Correct |
95 ms |
215428 KB |
Output is correct |
20 |
Correct |
98 ms |
216600 KB |
Output is correct |
21 |
Correct |
99 ms |
216648 KB |
Output is correct |
22 |
Correct |
103 ms |
216572 KB |
Output is correct |
23 |
Correct |
109 ms |
216448 KB |
Output is correct |
24 |
Correct |
110 ms |
217916 KB |
Output is correct |
25 |
Correct |
105 ms |
215764 KB |
Output is correct |
26 |
Correct |
103 ms |
216472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
214976 KB |
Output is correct |
2 |
Correct |
95 ms |
214868 KB |
Output is correct |
3 |
Correct |
86 ms |
214996 KB |
Output is correct |
4 |
Correct |
96 ms |
214908 KB |
Output is correct |
5 |
Correct |
101 ms |
215184 KB |
Output is correct |
6 |
Correct |
88 ms |
215056 KB |
Output is correct |
7 |
Correct |
93 ms |
214920 KB |
Output is correct |
8 |
Correct |
92 ms |
214976 KB |
Output is correct |
9 |
Correct |
91 ms |
215020 KB |
Output is correct |
10 |
Correct |
94 ms |
214912 KB |
Output is correct |
11 |
Correct |
93 ms |
215120 KB |
Output is correct |
12 |
Correct |
89 ms |
214864 KB |
Output is correct |
13 |
Correct |
97 ms |
215116 KB |
Output is correct |
14 |
Correct |
92 ms |
216408 KB |
Output is correct |
15 |
Correct |
97 ms |
215084 KB |
Output is correct |
16 |
Correct |
101 ms |
216584 KB |
Output is correct |
17 |
Correct |
101 ms |
215000 KB |
Output is correct |
18 |
Correct |
106 ms |
216492 KB |
Output is correct |
19 |
Correct |
95 ms |
215428 KB |
Output is correct |
20 |
Correct |
98 ms |
216600 KB |
Output is correct |
21 |
Correct |
99 ms |
216648 KB |
Output is correct |
22 |
Correct |
103 ms |
216572 KB |
Output is correct |
23 |
Correct |
109 ms |
216448 KB |
Output is correct |
24 |
Correct |
110 ms |
217916 KB |
Output is correct |
25 |
Correct |
105 ms |
215764 KB |
Output is correct |
26 |
Correct |
103 ms |
216472 KB |
Output is correct |
27 |
Correct |
323 ms |
264940 KB |
Output is correct |
28 |
Correct |
91 ms |
215384 KB |
Output is correct |
29 |
Correct |
118 ms |
221464 KB |
Output is correct |
30 |
Correct |
102 ms |
215084 KB |
Output is correct |
31 |
Correct |
275 ms |
264712 KB |
Output is correct |
32 |
Correct |
263 ms |
240316 KB |
Output is correct |
33 |
Correct |
330 ms |
264840 KB |
Output is correct |
34 |
Correct |
271 ms |
264328 KB |
Output is correct |
35 |
Correct |
388 ms |
264328 KB |
Output is correct |
36 |
Correct |
301 ms |
264072 KB |
Output is correct |
37 |
Runtime error |
264 ms |
274432 KB |
Execution killed with signal 9 |
38 |
Halted |
0 ms |
0 KB |
- |